Skip to content

Commit

Permalink
Configure to build on CircleCI (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Sep 12, 2019
1 parent 07cb831 commit 11af621
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 15 deletions.
67 changes: 67 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: 2.1

commands:
influxdb-restart:
steps:
- run:
name: "Start InfluxDB service"
command: ./scripts/influxdb-restart.sh
prepare:
description: "Prepare environment to tests"
steps:
- checkout
- influxdb-restart
client-test:
description: "Run tests"
parameters:
python-version:
type: string
default: &default-python-version "3"
steps:
- restore_cache:
name: Restoring Pip Cache
keys:
- &cache-key pip-cache-<< parameters.python-version >>-{{ checksum "requirements.txt" }}-{{ checksum "test-requirements.txt" }}
- pip-cache-<< parameters.python-version >>-
- run:
name: "Running tests"
command: |
docker run -it --rm \
--volume ${PWD}:/usr/src/project \
--volume ${PWD}/.cache:/root/.cache/pip/ \
--workdir /usr/src/project \
--network influx_network \
--env INFLUXDB_IP=192.168.0.2 \
python:<< parameters.python-version >> /bin/bash -c "./scripts/ci-test.sh"
- save_cache:
name: Saving Pip Cache
key: *cache-key
paths:
- ${PWD}/.cache
when: always
jobs:
tests-python-3:
machine: true
steps:
- prepare
- client-test:
python-version: *default-python-version
- store_test_results:
path: test-reports

workflows:
version: 2
build:
jobs:
- tests-python-3

nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- tests-python-3
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
### Bugs
1. [#3](https://github.com/bonitoo-io/influxdb-client-python/issues/3): The management API correctly supports inheritance defined in Influx API
1. [#7](https://github.com/bonitoo-io/influxdb-client-python/issues/7): Drop NaN and infinity values from fields when writing to InfluxDB

### CI
1. [#11](https://github.com/bonitoo-io/influxdb-client-python/pull/11): Switch CI to CircleCI
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# influxdb-client-python

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

InfluxDB 2.0 python client library. TODO...

Expand Down
3 changes: 2 additions & 1 deletion influxdb2_test/base_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import os
import re
import time
import unittest
Expand All @@ -18,7 +19,7 @@ class BaseTest(unittest.TestCase):

def setUp(self) -> None:
self.conf = influxdb2.configuration.Configuration()
self.host = "http://localhost:9999/api/v2"
self.host = "http://{0}:9999/api/v2".format(os.getenv("INFLUXDB_IP", "localhost"))
self.debug = False
self.auth_token = "my-token"
self.org = "my-org"
Expand Down
2 changes: 1 addition & 1 deletion influxdb2_test/test_gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_gzip_enabled(self):
def test_write_query_gzip(self):
httpretty.disable()

self.client = InfluxDBClient("http://localhost:9999/api/v2", token="my-token", org="my-org", debug=False,
self.client = InfluxDBClient(self.host, token="my-token", org="my-org", debug=False,
enable_gzip=True)
self.api_client = self.client.api_client
self.buckets_client = self.client.buckets_api()
Expand Down
21 changes: 21 additions & 0 deletions scripts/ci-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -e

#
# Install requirements
#
python --version
pip install -r requirements.txt
pip install -r test-requirements.txt

#
# Prepare for test results
#
mkdir test-reports || true

#
# Test
#
pytest influxdb2_test --junitxml=test-reports/junit.xml

26 changes: 14 additions & 12 deletions scripts/influxdb-restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ INFLUXDB_V2_IMAGE=${DOCKER_REGISTRY}influx:${INFLUXDB_V2_VERSION}

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

docker kill influxdb_v2 || true
docker rm influxdb_v2 || true
docker network rm influx_network || true
docker network create -d bridge influx_network --subnet 192.168.0.0/24 --gateway 192.168.0.1

#
# InfluxDB 2.0
Expand All @@ -40,12 +44,11 @@ echo
echo "Restarting InfluxDB 2.0 [${INFLUXDB_V2_IMAGE}] ... "
echo

docker kill my-influxdb2 || true
docker rm my-influxdb2 || true
docker pull ${INFLUXDB_V2_IMAGE} || true
docker run \
--detach \
--name my-influxdb2 \
--name influxdb_v2 \
--network influx_network \
--publish 9999:9999 \
${INFLUXDB_V2_IMAGE}

Expand All @@ -55,12 +58,11 @@ wget -S --spider --tries=20 --retry-connrefused --waitretry=5 http://localhost:9
echo
echo "Post onBoarding request, to setup initial user (my-user@my-password), org (my-org) and bucketSetup (my-bucket)"
echo

docker exec -it my-influxdb2 influx setup --username my-user --password my-password \
--token my-token --org my-org --bucket my-bucket --retention 48 --force

## show created orgId
ORGID=`docker exec -it my-influxdb2 influx org find | grep my-org | awk '{ print $1 }'`
echo "orgId="${ORGID}


curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \
-d '{
"username": "my-user",
"password": "my-password",
"org": "my-org",
"bucket": "my-bucket",
"token": "my-token"
}'

0 comments on commit 11af621

Please sign in to comment.