Skip to content

Commit 11af621

Browse files
authored
Configure to build on CircleCI (#11)
1 parent 07cb831 commit 11af621

File tree

7 files changed

+109
-15
lines changed

7 files changed

+109
-15
lines changed

.circleci/config.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: 2.1
2+
3+
commands:
4+
influxdb-restart:
5+
steps:
6+
- run:
7+
name: "Start InfluxDB service"
8+
command: ./scripts/influxdb-restart.sh
9+
prepare:
10+
description: "Prepare environment to tests"
11+
steps:
12+
- checkout
13+
- influxdb-restart
14+
client-test:
15+
description: "Run tests"
16+
parameters:
17+
python-version:
18+
type: string
19+
default: &default-python-version "3"
20+
steps:
21+
- restore_cache:
22+
name: Restoring Pip Cache
23+
keys:
24+
- &cache-key pip-cache-<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }}
25+
- pip-cache-<< parameters.python-version >>-
26+
- run:
27+
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_IP=192.168.0.2 \
35+
python:<< parameters.python-version >> /bin/bash -c "./scripts/ci-test.sh"
36+
- save_cache:
37+
name: Saving Pip Cache
38+
key: *cache-key
39+
paths:
40+
- ${PWD}/.cache
41+
when: always
42+
jobs:
43+
tests-python-3:
44+
machine: true
45+
steps:
46+
- prepare
47+
- client-test:
48+
python-version: *default-python-version
49+
- store_test_results:
50+
path: test-reports
51+
52+
workflows:
53+
version: 2
54+
build:
55+
jobs:
56+
- tests-python-3
57+
58+
nightly:
59+
triggers:
60+
- schedule:
61+
cron: "0 0 * * *"
62+
filters:
63+
branches:
64+
only:
65+
- master
66+
jobs:
67+
- tests-python-3

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
### Bugs
1111
1. [#3](https://github.com/bonitoo-io/influxdb-client-python/issues/3): The management API correctly supports inheritance defined in Influx API
1212
1. [#7](https://github.com/bonitoo-io/influxdb-client-python/issues/7): Drop NaN and infinity values from fields when writing to InfluxDB
13+
14+
### CI
15+
1. [#11](https://github.com/bonitoo-io/influxdb-client-python/pull/11): Switch CI to CircleCI

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# influxdb-client-python
22

3-
[![Build Status](https://travis-ci.org/bonitoo-io/influxdb-client-python.svg?branch=master)](https://travis-ci.org/bonitoo-io/influxdb-client-python)
3+
[![CircleCI](https://circleci.com/gh/bonitoo-io/influxdb-client-python.svg?style=svg)](https://circleci.com/gh/bonitoo-io/influxdb-client-python)
44

55
InfluxDB 2.0 python client library. TODO...
66

influxdb2_test/base_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import os
23
import re
34
import time
45
import unittest
@@ -18,7 +19,7 @@ class BaseTest(unittest.TestCase):
1819

1920
def setUp(self) -> None:
2021
self.conf = influxdb2.configuration.Configuration()
21-
self.host = "http://localhost:9999/api/v2"
22+
self.host = "http://{0}:9999/api/v2".format(os.getenv("INFLUXDB_IP", "localhost"))
2223
self.debug = False
2324
self.auth_token = "my-token"
2425
self.org = "my-org"

influxdb2_test/test_gzip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_gzip_enabled(self):
129129
def test_write_query_gzip(self):
130130
httpretty.disable()
131131

132-
self.client = InfluxDBClient("http://localhost:9999/api/v2", token="my-token", org="my-org", debug=False,
132+
self.client = InfluxDBClient(self.host, token="my-token", org="my-org", debug=False,
133133
enable_gzip=True)
134134
self.api_client = self.client.api_client
135135
self.buckets_client = self.client.buckets_api()

scripts/ci-test.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
#
6+
# Install requirements
7+
#
8+
python --version
9+
pip install -r requirements.txt
10+
pip install -r test-requirements.txt
11+
12+
#
13+
# Prepare for test results
14+
#
15+
mkdir test-reports || true
16+
17+
#
18+
# Test
19+
#
20+
pytest influxdb2_test --junitxml=test-reports/junit.xml
21+

scripts/influxdb-restart.sh

+14-12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}influx:${INFLUXDB_V2_VERSION}
3232

3333
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
3434

35+
docker kill influxdb_v2 || true
36+
docker rm influxdb_v2 || true
37+
docker network rm influx_network || true
38+
docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1
3539

3640
#
3741
# InfluxDB 2.0
@@ -40,12 +44,11 @@ echo
4044
echo "Restarting InfluxDB 2.0 [${INFLUXDB_V2_IMAGE}] ... "
4145
echo
4246

43-
docker kill my-influxdb2 || true
44-
docker rm my-influxdb2 || true
4547
docker pull ${INFLUXDB_V2_IMAGE} || true
4648
docker run \
4749
--detach \
48-
--name my-influxdb2 \
50+
--name influxdb_v2 \
51+
--network influx_network \
4952
--publish 9999:9999 \
5053
${INFLUXDB_V2_IMAGE}
5154

@@ -55,12 +58,11 @@ wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9
5558
echo
5659
echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
5760
echo
58-
59-
docker exec -it my-influxdb2 influx setup --username my-user --password my-password \
60-
--token my-token --org my-org --bucket my-bucket --retention 48 --force
61-
62-
## show created orgId
63-
ORGID=`docker exec -it my-influxdb2 influx org find | grep my-org | awk '{ print $1 }'`
64-
echo "orgId="${ORGID}
65-
66-
61+
curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
62+
-d '{
63+
"username": "my-user",
64+
"password": "my-password",
65+
"org": "my-org",
66+
"bucket": "my-bucket",
67+
"token": "my-token"
68+
}'

0 commit comments

Comments
 (0)