Skip to content

Commit d0c949a

Browse files
authored
chore(ci): testing over Python 3.6, 3.7 and 3.8 (influxdata#54)
1 parent 2b6b6ea commit d0c949a

File tree

7 files changed

+101
-54
lines changed

7 files changed

+101
-54
lines changed

.circleci/config.yml

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,63 @@
11
version: 2.1
22

33
commands:
4-
influxdb-restart:
4+
influxdb-onboarding:
55
steps:
66
- run:
7-
name: "Start InfluxDB service"
8-
command: ./scripts/influxdb-restart.sh
7+
name: "Post onBoarding request to InfluxDB 2"
8+
command: ./scripts/influxdb-onboarding.sh
99
prepare:
1010
description: "Prepare environment to tests"
1111
steps:
1212
- checkout
13-
- influxdb-restart
13+
- influxdb-onboarding
1414
client-test:
1515
description: "Run tests"
1616
parameters:
17-
python-version:
17+
python-image:
1818
type: string
19-
default: &default-python-version "3"
2019
steps:
2120
- restore_cache:
2221
name: Restoring Pip Cache
2322
keys:
24-
- &cache-key pip-cache-v2-<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }}
25-
- pip-cache-v2-<< parameters.python-version >>-
23+
- &cache-key pip-cache-v7-<< parameters.python-image >>-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }}-{{ checksum "extra-requirements.txt" }}
24+
- pip-cache-v7-<< parameters.python-image >>-
25+
- run:
26+
command: | # use pipenv to install dependencies
27+
sudo pip install pipenv
28+
pipenv install
2629
- run:
2730
name: "Running tests"
28-
command: |
29-
docker run -it --rm \
30-
--volume ${PWD}:/usr/src/project \
31-
--volume ${PWD}/.cache:/root/.cache/pip/ \
32-
--workdir /usr/src/project \
33-
--network influx_network \
34-
--env INFLUXDB_V2_URL="http://192.168.0.2:9999" \
35-
python:<< parameters.python-version >> /bin/bash -c "./scripts/ci-test.sh"
31+
command: ./scripts/ci-test.sh
3632
- save_cache:
3733
name: Saving Pip Cache
3834
key: *cache-key
3935
paths:
40-
- ./cache
36+
- ".venv"
37+
- "~/.cache/pip"
38+
# - "/usr/local/lib/python3.8/site-packages"
39+
# - "/usr/local/lib/python3.7/site-packages"
40+
# - "/usr/local/lib/python3.6/site-packages"
41+
- "/usr/local/lib/site-python"
4142
when: always
4243
jobs:
43-
tests-python-3:
44-
machine: true
44+
tests-python:
4545
parameters:
46-
influxdb-repository:
46+
python-image:
4747
type: string
48-
default: "influxdb"
49-
influxdb-version:
48+
default: "circleci/python:3.6-buster"
49+
influxdb-image:
5050
type: string
51-
default: "2.0.0-beta"
52-
environment:
53-
INFLUXDB_V2_REPOSITORY: << parameters.influxdb-repository >>
54-
INFLUXDB_V2_VERSION: << parameters.influxdb-version >>
51+
default: "influxdb:2.0.0-beta"
52+
docker:
53+
- image: << parameters.python-image >>
54+
environment: # environment variables for primary container
55+
PIPENV_VENV_IN_PROJECT: true
56+
- image: quay.io/influxdb/<< parameters.influxdb-image >>
5557
steps:
5658
- prepare
5759
- client-test:
58-
python-version: *default-python-version
60+
python-image: << parameters.python-image >>
5961
- store_test_results:
6062
path: test-reports
6163
- run:
@@ -66,12 +68,17 @@ workflows:
6668
version: 2
6769
build:
6870
jobs:
69-
- tests-python-3:
70-
name: test-beta
71-
- tests-python-3:
72-
name: test-nightly
73-
influxdb-repository: "influx"
74-
influxdb-version: "nightly"
71+
- tests-python:
72+
name: python-3.6
73+
- tests-python:
74+
name: python-3.6-nightly
75+
influxdb-image: "influx:nightly"
76+
- tests-python:
77+
name: python-3.7
78+
python-image: "circleci/python:3.7-buster"
79+
- tests-python:
80+
name: python-3.8
81+
python-image: "circleci/python:3.8-buster"
7582

7683
nightly:
7784
triggers:
@@ -82,4 +89,4 @@ workflows:
8289
only:
8390
- master
8491
jobs:
85-
- tests-python-3
92+
- tests-python

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
### Features
44
1. [#52](https://github.com/influxdata/influxdb-client-python/issues/52): Initialize client library from config file and environmental properties
55

6+
### CI
7+
1. [#54](https://github.com/influxdata/influxdb-client-python/pull/54): Add Python 3.7 and 3.8 to CI builds
8+
69
## 1.3.0 [2020-01-17]
710

811
### Features

scripts/ci-test.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ set -e
66
# Install requirements
77
#
88
python --version
9-
pip install -r requirements.txt
10-
pip install -r extra-requirements.txt
11-
pip install -r test-requirements.txt
12-
pip install pytest pytest-cov
13-
pip install twine
9+
pip install -r requirements.txt --user
10+
pip install -r extra-requirements.txt --user
11+
pip install -r test-requirements.txt --user
12+
pip install pytest pytest-cov --user
13+
pip install twine --user
1414
python setup.py sdist bdist_wheel
1515
twine check dist/*
1616

scripts/influxdb-onboarding.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
#
3+
# The MIT License
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
#
23+
24+
set -e
25+
26+
echo "Wait to start InfluxDB 2.0"
27+
wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics
28+
29+
echo
30+
echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
31+
echo
32+
curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
33+
-d '{
34+
"username": "my-user",
35+
"password": "my-password",
36+
"org": "my-org",
37+
"bucket": "my-bucket",
38+
"token": "my-token"
39+
}'

scripts/influxdb-restart.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,7 @@ docker run \
5757
echo "Wait to start InfluxDB 2.0"
5858
wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9999/metrics
5959

60-
echo
61-
echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
62-
echo
63-
curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
64-
-d '{
65-
"username": "my-user",
66-
"password": "my-password",
67-
"org": "my-org",
68-
"bucket": "my-bucket",
69-
"token": "my-token"
70-
}'
60+
#
61+
# Post onBoarding request to InfluxDB 2
62+
#
63+
"${SCRIPT_PATH}"/influxdb-onboarding.sh

tests/config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[influx2]
2-
url=http://192.168.0.2:9999
2+
url=http://localhost:9999
33
org=my-org
44
token=my-token
55
timeout=6000

tests/test_WriteApi.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,27 +463,28 @@ def tearDown(self) -> None:
463463

464464
def test_connection_option_from_conf_file(self):
465465
self.client.close()
466-
self.client = InfluxDBClient.from_config_file(os.getcwd() + "/tests/config.ini", self.debug)
466+
self.client = InfluxDBClient.from_config_file(self._path_to_config(), self.debug)
467467

468+
self.assertEqual("http://localhost:9999", self.client.url)
468469
self._check_connection_settings()
469470

470471
def test_connection_option_from_env(self):
471472
self.client.close()
472473
self.client = InfluxDBClient.from_env_properties(self.debug)
473474

475+
self.assertEqual("http://localhost:9999", self.client.url)
474476
self._check_connection_settings()
475477

476478
def _check_connection_settings(self):
477479
self.write_client = self.client.write_api(write_options=SYNCHRONOUS)
478480

479-
self.assertEqual(os.getenv("INFLUXDB_V2_URL"), self.client.url)
480481
self.assertEqual("my-org", self.client.org)
481482
self.assertEqual("my-token", self.client.token)
482483
self.assertEqual(6000, self.client.timeout)
483484

484485
def test_default_tags_from_conf_file(self):
485486
self.client.close()
486-
self.client = InfluxDBClient.from_config_file(os.getcwd() + "/tests/config.ini", self.debug)
487+
self.client = InfluxDBClient.from_config_file(self._path_to_config(), self.debug)
487488

488489
self._write_point()
489490

@@ -523,6 +524,10 @@ def _write_point(self):
523524

524525
self.delete_test_bucket(bucket)
525526

527+
@staticmethod
528+
def _path_to_config():
529+
return os.path.dirname(os.path.realpath(__file__)) + "/config.ini"
530+
526531

527532
if __name__ == '__main__':
528533
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy