Skip to content

Commit

Permalink
Upgrade python version in CI and test (#144)
Browse files Browse the repository at this point in the history
Upgrade Python from 3.5.2 to 3.8.5
Upgrade ci machine image to use ubuntu 20.04.
Extract pip install to separate script
Update README and add Makefile to help running tests.
Update python in the system testing
  • Loading branch information
miry authored Feb 1, 2021
1 parent ab160c5 commit 080a87f
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 27 deletions.
27 changes: 10 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
version: 2
jobs:
system_testing:
machine: true
machine:
image: ubuntu-2004:202010-01
steps:
- checkout
- run:
name: system.testing
command: |
pyenv global 3.5.2
python3 --version
pip3.5 --version
pip3.5 install --upgrade pip
pip3.5 install --upgrade setuptools
pip3.5 install docker
pip3.5 install docker-compose
pip3.5 install protobuf
pip3.5 install grpcio
sudo mkdir /test-log
sudo chmod a+rwx /test-log
export LOG_DIR=/test-log
./ci/do_ci.sh system.testing
./ci/system_testing.sh
- store_artifacts:
path: /test-log
path: ./test-log
build_gcc48:
docker:
- image: ubuntu:18.04
Expand Down Expand Up @@ -85,6 +74,10 @@ workflows:
only: /^v[0-9]+(\.[0-9]+)*$/
- system_testing
- build_gcc48
- docker_image
- openresty_docker_image
- docker_image:
requires:
- system_testing
- openresty_docker_image:
requires:
- system_testing
- module_binaries
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@
*.exe
*.out
*.app

# Python
__pycache__

# Test
test-log/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.5
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: test
test:
./ci/system_testing.sh

.PHONY: clean
clean:
rm -fr test-log
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ These can be dropped into existing NGINX installations provided that NGINX was c
the `--with-compat` option. See [example/trivial/ubuntu-x86_64](example/trivial/ubuntu-x86_64) for an
example of how to set it up.

Otherwise, nginx-opentracing can be used from the [Docker image](https://github.com/opentracing-contrib/nginx-opentracing#docker) or [built from source](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source).
Otherwise, nginx-opentracing can be used from the [Docker image](https://github.com/opentracing-contrib/nginx-opentracing#docker) or
[built from source](https://github.com/opentracing-contrib/nginx-opentracing#building-from-source).

Getting Started
---------------
First, write a configuration for the tracer used. Below's an example of what
a Jaeger configuration might look like:

/etc/jaeger-nginx-config.json
```
```json
{
"service_name": "nginx",
"sampler": {
Expand Down Expand Up @@ -157,3 +158,11 @@ wget -O - https://github.com/DataDog/dd-opentracing-cpp/releases/download/v0.3.0
```

Testing
--------

Run tests on local machine requires `pyenv` and tested against version 3.8.5.

```shell
$ make test
```
2 changes: 1 addition & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ elif [[ "$1" == "module.binaries" ]]; then
elif [[ "$1" == "push_docker_image" ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
VERSION_TAG="`git describe --abbrev=0 --tags`"
VERSION="${VERSION_TAG/v/}"
VERSION="${VERSION_TAG/v/}"
# nginx
docker build -t opentracing/nginx-opentracing .
docker tag opentracing/nginx-opentracing opentracing/nginx-opentracing:${VERSION}
Expand Down
12 changes: 12 additions & 0 deletions ci/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -x
set -e

pyenv versions
pyenv local 3.8.5
python --version
pip --version
pip install --upgrade pip
pip install --upgrade setuptools
pip install -r test/requirements.ci.txt
9 changes: 9 additions & 0 deletions ci/system_testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

./ci/install_dependencies.sh

set -x
mkdir ./test-log
chmod a+rwx ./test-log
export LOG_DIR=$PWD/test-log
./ci/do_ci.sh system.testing
19 changes: 15 additions & 4 deletions test/Dockerfile-backend
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM ubuntu:20.04
RUN apt-get update -y
RUN apt-get install -y curl python-dev build-essential
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py

RUN apt-get update \
&& apt-get install -y \
curl \
python3 \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3 get-pip.py \
&& rm get-pip.py

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt
ENTRYPOINT ["python"]

ENTRYPOINT ["python3"]
CMD ["environment/app.py"]
6 changes: 3 additions & 3 deletions test/nginx_opentracing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def setUp(self):
os.chdir(self.workdir)

# Make sure trace output is writable
os.chmod(os.path.join(self.workdir, "traces", "nginx.json"),
os.chmod(os.path.join(self.workdir, "traces", "nginx.json"),
stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

self.environment_handle = subprocess.Popen(["docker-compose", "up"],
stdout=subprocess.PIPE,
self.environment_handle = subprocess.Popen(["docker-compose", "up"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
self.client = docker.from_env()
timeout = time.time() + 60
Expand Down
8 changes: 8 additions & 0 deletions test/requirements.ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docker==4.3.1
requests==2.24.0
websocket-client==0.57.0
urllib3==1.25.11
docker-compose==1.27.4
grpcio==1.33.2
protobuf==3.13.0

0 comments on commit 080a87f

Please sign in to comment.