Skip to content

Commit

Permalink
Update scripts, Dockerfile to run level one integ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bonicim committed Jul 21, 2020
1 parent 68dbb45 commit 9957c90
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ __pycache__
start-rabbitmq
stop-rabbitmq
rabbitmq.log
*.result.txt
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions ci-integration/run-test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions ci-integration/virtualization/Dockerfile.testing
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
9 changes: 7 additions & 2 deletions ci-integration/virtualization/requirements_test.txt
Original file line number Diff line number Diff line change
@@ -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
pandas
watchdog==0.10.2
watchdog-gevent==0.1.1
cryptography==2.3
docker
psycopg2
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 23 additions & 1 deletion volttrontesting/platform/dbutils/test_postgresqlfuncts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(
Expand All @@ -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
):
Expand Down Expand Up @@ -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
):
Expand All @@ -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
):
Expand Down Expand Up @@ -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
):
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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
):
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
):
Expand Down

0 comments on commit 9957c90

Please sign in to comment.