diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4b2c3555..2706190a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,7 @@ env: SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }} SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }} GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + STEAMPIPE_LOG: info jobs: goreleaser: @@ -195,20 +196,6 @@ jobs: path: ~/.steampipe/logs if-no-files-found: error - - name: Check steampipe processes running - continue-on-error: true - run: | - ps -ef | grep "steampipe" - - - name: Verify No Steampipe Processes Running - continue-on-error: false - run: | - if [ $(ps aux | grep steampipe | grep -v bats |grep -v grep | wc -l | tr -d ' ') -eq 0 ]; then - exit 0 - else - exit 1 - fi - # This job checks whether the test suite has passed or not. # Since the exit_code is set only when the bats test suite pass, # we have added the if-conditional block diff --git a/tests/acceptance/test_files/blank_aggregators.bats b/tests/acceptance/test_files/blank_aggregators.bats index 8fd8b2fb5..8b9fb1820 100644 --- a/tests/acceptance/test_files/blank_aggregators.bats +++ b/tests/acceptance/test_files/blank_aggregators.bats @@ -33,3 +33,12 @@ load "$LIB_BATS_SUPPORT/load.bash" steampipe service stop assert_equal "$output" "null" } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/brew.bats b/tests/acceptance/test_files/brew.bats index 9dc18f806..a627e6b75 100644 --- a/tests/acceptance/test_files/brew.bats +++ b/tests/acceptance/test_files/brew.bats @@ -19,3 +19,12 @@ load "$LIB_BATS_SUPPORT/load.bash" # steampipe completion should not create INSTALL DIRs assert_equal $directory_count 0 } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/cache.bats b/tests/acceptance/test_files/cache.bats index 6e82b703a..3cb87208c 100644 --- a/tests/acceptance/test_files/cache.bats +++ b/tests/acceptance/test_files/cache.bats @@ -358,3 +358,12 @@ load "$LIB_BATS_SUPPORT/load.bash" rm -f output1.json rm -f output2.json } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/chaos_and_query.bats b/tests/acceptance/test_files/chaos_and_query.bats index b61af4b47..c30e48fdb 100644 --- a/tests/acceptance/test_files/chaos_and_query.bats +++ b/tests/acceptance/test_files/chaos_and_query.bats @@ -204,4 +204,13 @@ load "$LIB_BATS_SUPPORT/load.bash" steampipe query "select 1 as a" --output json run steampipe query "select 1 as a" --output json assert_equal "$output" "$(cat $TEST_DATA_DIR/expected_15.json)" +} + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 } \ No newline at end of file diff --git a/tests/acceptance/test_files/check.bats b/tests/acceptance/test_files/check.bats index dad99e291..f39aa4e88 100644 --- a/tests/acceptance/test_files/check.bats +++ b/tests/acceptance/test_files/check.bats @@ -273,3 +273,12 @@ load "$LIB_BATS_SUPPORT/load.bash" # contains `summary` assert_output --partial 'Summary' } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/cloud.bats b/tests/acceptance/test_files/cloud.bats index a684925ea..632f002e4 100644 --- a/tests/acceptance/test_files/cloud.bats +++ b/tests/acceptance/test_files/cloud.bats @@ -72,6 +72,15 @@ load "$LIB_BATS_SUPPORT/load.bash" # assert_equal "$(echo $QUERY_TIME '<' $TIME_TO_QUERY | bc -l)" "1" } +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} + function setup() { if [[ -z "${SPIPETOOLS_PG_CONN_STRING}" || -z "${SPIPETOOLS_TOKEN}" ]]; then diff --git a/tests/acceptance/test_files/dashboard.bats b/tests/acceptance/test_files/dashboard.bats index e8c7b4b5f..d7c8a3e8c 100644 --- a/tests/acceptance/test_files/dashboard.bats +++ b/tests/acceptance/test_files/dashboard.bats @@ -111,3 +111,12 @@ load "$LIB_BATS_SUPPORT/load.bash" # check if there is no diff returned by the script assert_equal "$diff" "" } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/dashboard_parsing_validation.bats b/tests/acceptance/test_files/dashboard_parsing_validation.bats index 872330a68..7440b563f 100644 --- a/tests/acceptance/test_files/dashboard_parsing_validation.bats +++ b/tests/acceptance/test_files/dashboard_parsing_validation.bats @@ -65,3 +65,12 @@ load "$LIB_BATS_SUPPORT/load.bash" run steampipe dashboard dashboard.node_edge_providers_nested --output snapshot assert_output --partial 'does not define a query or SQL, and has no edges/nodes' } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/dynamic_aggregators.bats b/tests/acceptance/test_files/dynamic_aggregators.bats index 7d8cba863..b658abc47 100644 --- a/tests/acceptance/test_files/dynamic_aggregators.bats +++ b/tests/acceptance/test_files/dynamic_aggregators.bats @@ -96,3 +96,12 @@ load "$LIB_BATS_SUPPORT/load.bash" function setup_file() { export STEAMPIPE_SYNC_REFRESH=true } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/dynamic_schema.bats b/tests/acceptance/test_files/dynamic_schema.bats index 9eca73667..c20c78db0 100644 --- a/tests/acceptance/test_files/dynamic_schema.bats +++ b/tests/acceptance/test_files/dynamic_schema.bats @@ -61,6 +61,15 @@ load "$LIB_BATS_SUPPORT/load.bash" rm -f $FILE_PATH/test_data/csv_plugin_test/b.csv } +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} + function setup() { # install csv plugin diff --git a/tests/acceptance/test_files/exit_codes.bats b/tests/acceptance/test_files/exit_codes.bats index 1043e7a8b..c4eb1ca1e 100644 --- a/tests/acceptance/test_files/exit_codes.bats +++ b/tests/acceptance/test_files/exit_codes.bats @@ -29,3 +29,12 @@ load "$LIB_BATS_SUPPORT/load.bash" echo $status [ $status -eq 0 ] } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/force_stop.bats b/tests/acceptance/test_files/force_stop.bats index 9acf9db27..0e9a8d3f0 100644 --- a/tests/acceptance/test_files/force_stop.bats +++ b/tests/acceptance/test_files/force_stop.bats @@ -38,3 +38,12 @@ load "$LIB_BATS_SUPPORT/load.bash" run steampipe service stop --force assert_success } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/introspection.bats b/tests/acceptance/test_files/introspection.bats index 8ca43aab5..07c7dc272 100644 --- a/tests/acceptance/test_files/introspection.bats +++ b/tests/acceptance/test_files/introspection.bats @@ -340,3 +340,12 @@ load "$LIB_BATS_SUPPORT/load.bash" assert_equal "$(cat output.json)" "$(cat $TEST_DATA_DIR/expected_introspection_check_where.json)" rm -f output.json* } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/migration.bats b/tests/acceptance/test_files/migration.bats index a9c80cd64..c9c2cae6c 100644 --- a/tests/acceptance/test_files/migration.bats +++ b/tests/acceptance/test_files/migration.bats @@ -82,3 +82,23 @@ load "$LIB_BATS_SUPPORT/load.bash" rm -rf $tmpdir rm -f verify* } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} + +function setup() { + # skip if this test is run on Linux ARM64, since there is no linux_arm binary available + # for v0.13.6 to run this test + sys=$(uname -sm) + if [[ "$sys" == "Linux aarch64" ]]; then + skip + else + echo "Running migration test..." + fi +} diff --git a/tests/acceptance/test_files/mod.bats b/tests/acceptance/test_files/mod.bats index a9e002675..b315f5d0a 100644 --- a/tests/acceptance/test_files/mod.bats +++ b/tests/acceptance/test_files/mod.bats @@ -444,3 +444,12 @@ v3.0.0,v3.0.0,ok' rm -rf .steampipe/ rm -rf .mod.cache.json } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/mod_install.bats b/tests/acceptance/test_files/mod_install.bats index 5c182c686..f3d0fa12e 100644 --- a/tests/acceptance/test_files/mod_install.bats +++ b/tests/acceptance/test_files/mod_install.bats @@ -139,6 +139,15 @@ top_level.benchmark.bm_version_dependency_mod_1,Benchmark version dependency mod top_level.benchmark.bm_version_dependency_mod_2,Benchmark version dependency mod 2,,dependency_2.control.version,,,3,3,ok,' } +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} + function teardown() { rm -rf .steampipe/ rm -rf .mod.cache.json diff --git a/tests/acceptance/test_files/mod_require.bats b/tests/acceptance/test_files/mod_require.bats index 549fda352..4a4efb68a 100644 --- a/tests/acceptance/test_files/mod_require.bats +++ b/tests/acceptance/test_files/mod_require.bats @@ -161,3 +161,12 @@ Error: could not find plugin which satisfies requirement 'gcp' in 'mod.bad_mod_w # block is added assert_output --partial "1" } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/schema_cloning.bats b/tests/acceptance/test_files/schema_cloning.bats index ac1f3b496..99d442f6f 100644 --- a/tests/acceptance/test_files/schema_cloning.bats +++ b/tests/acceptance/test_files/schema_cloning.bats @@ -23,3 +23,17 @@ load "$LIB_BATS_SUPPORT/load.bash" run steampipe query "select * from chaos2.chaos_all_column_types" assert_success } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} + +function teardown() { + # remove the files created as part of these tests + rm -f $STEAMPIPE_INSTALL_DIR/config/two_chaos.spc +} diff --git a/tests/acceptance/test_files/search_path.bats b/tests/acceptance/test_files/search_path.bats index f3d08753b..118793b61 100644 --- a/tests/acceptance/test_files/search_path.bats +++ b/tests/acceptance/test_files/search_path.bats @@ -58,3 +58,12 @@ load "$LIB_BATS_SUPPORT/load.bash" run steampipe query "show search_path" --search-path foo1,steampipe_internal,foo2 assert_output "$(cat $TEST_DATA_DIR/expected_search_path_internal_schema_once_2.txt)" } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/service.bats b/tests/acceptance/test_files/service.bats index ea08e6b19..cecfca481 100644 --- a/tests/acceptance/test_files/service.bats +++ b/tests/acceptance/test_files/service.bats @@ -82,4 +82,13 @@ load "$LIB_BATS_SUPPORT/load.bash" rm -rf $tmpdir assert_success -} \ No newline at end of file +} + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/service_and_plugin.bats b/tests/acceptance/test_files/service_and_plugin.bats index 277ae9942..834083554 100644 --- a/tests/acceptance/test_files/service_and_plugin.bats +++ b/tests/acceptance/test_files/service_and_plugin.bats @@ -478,3 +478,12 @@ function setup_file() { export BATS_TEST_TIMEOUT=60 echo "# setup_file()">&3 } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} \ No newline at end of file diff --git a/tests/acceptance/test_files/snapshot.bats b/tests/acceptance/test_files/snapshot.bats index f62582f46..570d62b5e 100644 --- a/tests/acceptance/test_files/snapshot.bats +++ b/tests/acceptance/test_files/snapshot.bats @@ -100,3 +100,12 @@ function setup() { # delete the snapshot from cloud workspace to avoid exceeding quota curl -X DELETE "$req_url" -H "Authorization: Bearer $SPIPETOOLS_TOKEN" } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +} diff --git a/tests/acceptance/test_files/workspace.bats b/tests/acceptance/test_files/workspace.bats index 5fcb4aa8f..6f4315926 100644 --- a/tests/acceptance/test_files/workspace.bats +++ b/tests/acceptance/test_files/workspace.bats @@ -106,3 +106,12 @@ load "$LIB_BATS_SUPPORT/load.bash" assert_equal "$err" "" rm -f err } + +function teardown_file() { + # list running processes + ps -ef | grep steampipe + + # check if any processes are running + num=$(ps aux | grep steampipe | grep -v bats | grep -v grep | grep -v tests/acceptance | wc -l | tr -d ' ') + assert_equal $num 0 +}