diff --git a/.gitignore b/.gitignore index 87049d3c03..dac1b08154 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ __pycache__ start-rabbitmq stop-rabbitmq rabbitmq.log +*.result.txt diff --git a/.travis.yml b/.travis.yml index 918f64cd30..35fffe3487 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python2.7 # Each array entry will execute 1 job. env: - NUM_PROCESSES=10 CI="travis" + - NUM_PROCESSES=10 CI="travis" FAST_FAIL=false services: - docker diff --git a/ci-integration/run-test-docker.sh b/ci-integration/run-test-docker.sh index 8c9bfc41d1..3f52194ff2 100755 --- a/ci-integration/run-test-docker.sh +++ b/ci-integration/run-test-docker.sh @@ -69,8 +69,16 @@ run_test(){ echo "Running test module $filename" base_filename="$(basename "$filename")" # Start the docker run module. - docker run -e "IGNORE_ENV_CHECK=1" --name "$base_filename" \ - -t volttron_test_image pytest "$filename" > "$base_filename.result.txt" 2>&1 & + # Run a specific script for level one integration tests + if [[ $filename =~ "volttrontesting/platform/dbutils/"* ]]; then + docker run -e "IGNORE_ENV_CHECK=1" --name "$base_filename" \ + -t --network="host" -v /var/run/docker.sock:/var/run/docker.sock volttron_test_image pytest -m dbutils \ + "$filename" > "$base_filename.result.txt" 2>&1 & + else + docker run -e "IGNORE_ENV_CHECK=1" --name "$base_filename" \ + -t volttron_test_image pytest "$filename" > "$base_filename.result.txt" 2>&1 & + fi + runningprocs+=($!) outputfiles+=("$base_filename.result.txt") containernames+=("$base_filename") @@ -113,9 +121,11 @@ process_pid(){ if [[ ${FAST_FAIL} -eq 0 && -n ${CI} ]]; then docker logs "${containernames[$index]}" fi - if [[ ${FAST_FAIL} -eq 0 ]]; then + if ${FAST_FAIL}; then echo "Exiting cleanly now!" exit_cleanly + else + echo "Test failed. Keep running rest of tests." fi fi else diff --git a/ci-integration/virtualization/Dockerfile.testing b/ci-integration/virtualization/Dockerfile.testing index c1e87390ef..ded9c5401a 100644 --- a/ci-integration/virtualization/Dockerfile.testing +++ b/ci-integration/virtualization/Dockerfile.testing @@ -11,4 +11,23 @@ RUN echo "export VOLTTRON_ROOT=${VOLTTRON_ROOT}" > /home/volttron/.bashrc && \ USER root WORKDIR ${VOLTTRON_ROOT} + +RUN apt-get update +RUN apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common \ + apt-utils +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - +RUN add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/debian \ + $(lsb_release -cs) \ + stable" +RUN apt-get update +RUN apt-get install docker-ce docker-ce-cli containerd.io -y + +RUN usermod -aG docker $VOLTTRON_USER + ENTRYPOINT ["/startup/entrypoint.sh"] diff --git a/ci-integration/virtualization/requirements_test.txt b/ci-integration/virtualization/requirements_test.txt index 6f11e8a3c9..3a4be3a2f9 100644 --- a/ci-integration/virtualization/requirements_test.txt +++ b/ci-integration/virtualization/requirements_test.txt @@ -1,7 +1,12 @@ more-itertools>=4.0.0 -pytest==3.6.4 +pytest==5.4.3 pytest-timeout mock websocket-client numpy>1.13<2 -pandas \ No newline at end of file +pandas +watchdog==0.10.2 +watchdog-gevent==0.1.1 +cryptography==2.3 +docker +psycopg2 diff --git a/pytest.ini b/pytest.ini index f80296468f..e9ff0d1751 100644 --- a/pytest.ini +++ b/pytest.ini @@ -53,3 +53,4 @@ markers = secure: Test platform and agents with secure platform options mysqlfuncts: level one integration tests for mysqlfuncts postgresqlfuncts: level one integration tests for postgresqlfuncts + dbutils: test all the level one integrations tests for dbfuncts classes diff --git a/volttrontesting/platform/dbutils/test_postgresqlfuncts.py b/volttrontesting/platform/dbutils/test_postgresqlfuncts.py index 56f97b6c4f..a46b035c74 100644 --- a/volttrontesting/platform/dbutils/test_postgresqlfuncts.py +++ b/volttrontesting/platform/dbutils/test_postgresqlfuncts.py @@ -14,7 +14,7 @@ # Current documentation claims that we have tested Historian on Postgres 10 # See https://volttron.readthedocs.io/en/develop/core_services/historians/SQL-Historian.html#postgresql-and-redshift IMAGES = ["postgres:10"] -ALLOW_CONNECTION_TIME = 2 +ALLOW_CONNECTION_TIME = 3 TEST_DATABASE = "test_historian" ROOT_USER = "postgres" ROOT_PASSWORD = "password" @@ -32,6 +32,7 @@ @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_setup_historian_tables_should_create_tables(get_container_func, ports_config): get_container, image = get_container_func with get_container( @@ -53,6 +54,7 @@ def test_setup_historian_tables_should_create_tables(get_container_func, ports_c @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_record_table_definitions_should_create_meta_table( get_container_func, ports_config ): @@ -81,6 +83,7 @@ def test_record_table_definitions_should_create_meta_table( @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_read_tablenames_from_db_should_return_table_names( get_container_func, ports_config ): @@ -107,6 +110,7 @@ def test_read_tablenames_from_db_should_return_table_names( @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_setup_aggregate_historian_tables_should_create_aggregate_tables( get_container_func, ports_config ): @@ -161,6 +165,7 @@ def test_setup_aggregate_historian_tables_should_create_aggregate_tables( ], ) @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_query_should_return_data( get_container_func, ports_config, topic_ids, id_name_map, expected_values ): @@ -184,6 +189,7 @@ def test_query_should_return_data( @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_topic_should_return_topic_id(get_container_func, ports_config): get_container, image = get_container_func @@ -205,6 +211,7 @@ def test_insert_topic_should_return_topic_id(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_agg_topic_should_return_agg_topic_id(get_container_func, ports_config): get_container, image = get_container_func @@ -231,6 +238,7 @@ def test_insert_agg_topic_should_return_agg_topic_id(get_container_func, ports_c @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_meta_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -253,6 +261,7 @@ def test_insert_meta_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_data_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -276,6 +285,7 @@ def test_insert_data_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_update_topic_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -300,6 +310,7 @@ def test_update_topic_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_get_aggregation_list_should_return_list(get_container_func, ports_config): get_container, image = get_container_func @@ -333,6 +344,7 @@ def test_get_aggregation_list_should_return_list(get_container_func, ports_confi @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_agg_topic_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -358,6 +370,7 @@ def test_insert_agg_topic_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_update_agg_topic_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -391,6 +404,7 @@ def test_update_agg_topic_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_agg_meta_should_return_true(get_container_func, ports_config): get_container, image = get_container_func @@ -414,6 +428,7 @@ def test_insert_agg_meta_should_return_true(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_get_topic_map_should_return_maps(get_container_func, ports_config): get_container, image = get_container_func @@ -443,6 +458,7 @@ def test_get_topic_map_should_return_maps(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_get_agg_topics_should_return_list(get_container_func, ports_config): get_container, image = get_container_func @@ -470,6 +486,7 @@ def test_get_agg_topics_should_return_list(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_get_agg_topic_map_should_return_dict(get_container_func, ports_config): get_container, image = get_container_func @@ -495,6 +512,7 @@ def test_get_agg_topic_map_should_return_dict(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_query_topics_by_pattern_should_return_matching_results( get_container_func, ports_config ): @@ -526,6 +544,7 @@ def test_query_topics_by_pattern_should_return_matching_results( @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_create_aggregate_store_should_succeed(get_container_func, ports_config): get_container, image = get_container_func @@ -552,6 +571,7 @@ def test_create_aggregate_store_should_succeed(get_container_func, ports_config) @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_insert_aggregate_stmt_should_succeed(get_container_func, ports_config): get_container, image = get_container_func @@ -605,6 +625,7 @@ def test_insert_aggregate_stmt_should_succeed(get_container_func, ports_config): @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_collect_aggregate_stmt_should_return_rows(get_container_func, ports_config): get_container, image = get_container_func @@ -634,6 +655,7 @@ def test_collect_aggregate_stmt_should_return_rows(get_container_func, ports_con @pytest.mark.postgresqlfuncts +@pytest.mark.dbutils def test_collect_aggregate_stmt_should_raise_value_error( get_container_func, ports_config ):