diff --git a/surveil/tests/integration/integration.yml b/surveil/tests/integration/integration.yml new file mode 100644 index 0000000..d81a588 --- /dev/null +++ b/surveil/tests/integration/integration.yml @@ -0,0 +1,30 @@ +surveil: + build: . + links: + - mongo + - influxdb + - alignak + ports: + - "8999:8080" + command: bash -c "cd /opt/surveil && ./setup.sh && python setup.py develop && ((sleep 40 && surveil-init --demo) &) && sleep 20 && surveil-api --reload" + +alignak: + build: tools/docker/alignak_container/ + links: + - mongo + - influxdb + environment: + SURVEIL_OS_AUTH_URL: "http://keystone:5000/v2.0" + SURVEIL_OS_USERNAME: "admin" + SURVEIL_OS_PASSWORD: "password" + SURVEIL_OS_TENANT_NAME: "admin" + +mongo: + image: mongo + command: + "mongod --nojournal --smallfiles" + +influxdb: + image: savoirfairelinux/influxdb + environment: + PRE_CREATE_DB: "db" diff --git a/surveil/tests/integration/integration_test.py b/surveil/tests/integration/integration_test.py index 7f9eff1..c5454a7 100644 --- a/surveil/tests/integration/integration_test.py +++ b/surveil/tests/integration/integration_test.py @@ -37,8 +37,17 @@ class MergedIntegrationTest(base.BaseTestCase): os.path.dirname(os.path.realpath(__file__)), "../../../") ) - compose_file = os.path.join(surveil_dir, 'docker-compose.yml') - project_config = compose_config.load(compose_file) + + compose_file = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + 'integration.yml' + ) + + project_config = compose_config.from_dictionary( + compose_config.load_yaml(compose_file), + working_dir=surveil_dir, + filename=compose_file + ) cls.project = compose_project.Project.from_dicts( "surveilintegrationtest", @@ -50,8 +59,8 @@ class MergedIntegrationTest(base.BaseTestCase): cls.project.up() cls.client = sclient.Client( - 'http://localhost:8080/v2', - auth_url='http://localhost:8080/v2/auth', + 'http://localhost:8999/v2', + auth_url='http://localhost:8999/v2/auth', version='2_0' ) diff --git a/surveil/tests/integration/test_surveil.py b/surveil/tests/integration/test_surveil.py index 37b72d4..6fb47e8 100644 --- a/surveil/tests/integration/test_surveil.py +++ b/surveil/tests/integration/test_surveil.py @@ -23,7 +23,7 @@ class TestMergedIngegrationSurveil( def test_hello(self): self.assertEqual( - requests.get("http://localhost:8080/v2/hello").text, + requests.get("http://localhost:8999/v2/hello").text, 'Hello World!' ) @@ -67,3 +67,31 @@ class TestSeparatedIntegrationSurveil( message="Could not find host in status." ) ) + + def test_delete_host(self): + self.test_create_host() + + TestSeparatedIntegrationSurveil.client.config.hosts.delete( + 'integrationhosttest' + ) + + TestSeparatedIntegrationSurveil.client.config.reload_config() + + def function(): + # TODO(aviau): Use status API + status_hosts = (TestSeparatedIntegrationSurveil. + client.config.hosts.list()) + self.assertFalse( + any(host['host_name'].decode() == 'integrationhosttest' + for host in status_hosts) + ) + + self.assertTrue( + self.try_for_x_seconds( + function, + time_to_wait=180, + cooldown=10, + exception=AssertionError, + message="Host was not deleted" + ) + ) diff --git a/test-requirements.txt b/test-requirements.txt index 8476ab8..6c4b66e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,4 +9,4 @@ mongomock httpretty==0.8.3 sphinx_rtd_theme docker-compose -python-surveilclient +python-surveilclient==0.6.0