From 0bb982a87fc621933fc84c2c1de6e2210b554295 Mon Sep 17 00:00:00 2001 From: Andrew Zong Date: Thu, 13 Feb 2020 07:43:58 +0800 Subject: [PATCH] setup travis. --- .travis.yml | 14 ++++++----- requirements.txt | 1 + test/travis/01.kibana-01-curl-ready.py | 16 +++++++++++++ .../01.kibana-02-dashboards-imported.py | 23 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 requirements.txt create mode 100644 test/travis/01.kibana-01-curl-ready.py create mode 100644 test/travis/01.kibana-02-dashboards-imported.py diff --git a/.travis.yml b/.travis.yml index f80e98d..62372a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,23 +10,25 @@ services: - docker env: - - DOCKER_COMPOSE_VERSION=1.25.2 + - DOCKER_COMPOSE_VERSION=v1.25.2 before_install: - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin + - sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose -install: +install: # install from requirements.txt script: - # clone - # run start-all.sh - + - ./scripts/start-all.sh + - docker ps + - set -ex + - for n in `ls test/travis/*.py`; do python $n; done + - set +x -test: # docker exec CTRLBOX python /root/workdir/test/send-to-fluentd/20001-fake-1-logging.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e20605c --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.22.0 \ No newline at end of file diff --git a/test/travis/01.kibana-01-curl-ready.py b/test/travis/01.kibana-01-curl-ready.py new file mode 100644 index 0000000..19ca862 --- /dev/null +++ b/test/travis/01.kibana-01-curl-ready.py @@ -0,0 +1,16 @@ +import requests +import sys + +kibana_uri = 'http://localhost:5601/app/kibana' + +try: + resp = requests.get(kibana_uri) +except Exception as e: + print("Failed to get %s: %s" % (kibana_uri, e.message)) + sys.exit(1) +else: + if resp.status_code == 200: + sys.exit(0) + else: + print("kibana response with: %s" % resp.reason) + sys.exit(1) diff --git a/test/travis/01.kibana-02-dashboards-imported.py b/test/travis/01.kibana-02-dashboards-imported.py new file mode 100644 index 0000000..00f1dba --- /dev/null +++ b/test/travis/01.kibana-02-dashboards-imported.py @@ -0,0 +1,23 @@ +import requests +import sys +import json + +kibana_uri = 'http://localhost:5601/api/saved_objects/_find?type=dashboard&fields=id&fields=title' + +try: + resp = requests.get(kibana_uri) +except Exception as e: + print("Failed to get %s: %s" % (kibana_uri, e.message)) + sys.exit(1) +else: + if resp.status_code == 200: + jd = resp.json() + if (jd['total'] != 0): + print("total dashboards: %d" % jd['total']) + sys.exit(0) + else: + print("kibana response with 0 dashboards: %s" % json.dumps(jd)) + sys.exit(1) + else: + print("kibana response with: %s" % resp.reason) + sys.exit(1)