diff --git a/CHANGELOG.md b/CHANGELOG.md index 67cfa18c..9b9f7c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2023-10-28 +* Refactor st2test, install BATS via `apt install` +* Remove unneeded file st2test-tools.sh +* Fix ST2_AUTH_URL and ST2_STREAM_URL + ## 2022-05-06 * Migrate to Ubuntu 20 / Python 3.8 based containers diff --git a/tests/st2tests-tools.sh b/tests/st2tests-tools.sh deleted file mode 100644 index aa96d2ce..00000000 --- a/tests/st2tests-tools.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -mkdir -p ${BATS_HELPERS_DIR} ${BATS_DIR} -cp -R /opt/bats/* ${BATS_DIR} -cp -R /opt/bats-helpers/* ${BATS_HELPERS_DIR} diff --git a/tests/st2tests.sh b/tests/st2tests.bat similarity index 89% rename from tests/st2tests.sh rename to tests/st2tests.bat index 36386eb3..495d9c17 100755 --- a/tests/st2tests.sh +++ b/tests/st2tests.bat @@ -1,19 +1,19 @@ -#!/usr/bin/env bats +# bats smoke-tests -load "${BATS_HELPERS_DIR}/bats-support/load.bash" -load "${BATS_HELPERS_DIR}/bats-assert/load.bash" -load "${BATS_HELPERS_DIR}/bats-file/load.bash" +load "/tools/bats-support/load.bash" +load "/tools/bats-assert/load.bash" +load "/tools/bats-file/load.bash" @test 'st2 version deployed and python env are as expected' { run st2 --version assert_success - # st2 3.7.0, on Python 3.8.10 + # st2 3.8.0, on Python 3.8.10 assert_line --partial "st2 ${ST2_VERSION}" assert_line --partial 'on Python 3.8.10' } @test 'ST2_AUTH_URL service endpoint is accessible and working' { - run curl -v ${ST2_API_URL} + run curl -v ${ST2_AUTH_URL} assert_line --partial 'Content-Type: application/json' assert_line --partial 'St2-Api-Key' } @@ -25,7 +25,7 @@ load "${BATS_HELPERS_DIR}/bats-file/load.bash" } @test 'ST2_STREAM_URL service endpoint is accessible and working' { - run curl -v ${ST2_API_URL} + run curl -v ${ST2_STREAM_URL} assert_line --partial 'Content-Type: application/json' assert_line --partial 'St2-Api-Key' } diff --git a/tests/st2tests.yaml b/tests/st2tests.yaml index b06a8e06..cca86daf 100644 --- a/tests/st2tests.yaml +++ b/tests/st2tests.yaml @@ -8,30 +8,27 @@ services: ST2_API_URL: ${ST2_API_URL:-http://st2api:9101/} ST2_STREAM_URL: ${ST2_STREAM_URL:-http://st2stream:9102/} ST2WEB_HTTPS: ${ST2WEB_HTTPS:-0} - BATS_HELPERS_DIR: /tools/bats-helpers/ ST2_AUTH_USERNAME: ${ST2_AUTH_USERNAME:-st2admin} ST2_AUTH_PASSWORD: ${ST2_AUTH_PASSWORD:-Ch@ngeMe} - command: bash -c "ln -s /tools/bats/libexec/bats /sbin/bats && /st2tests.sh" + command: + - bash + - -ec + - | + apt update > /dev/null 2>&1 + apt install bats -y > /dev/null 2>&1 + mkdir /tools + git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \ + https://github.com/ztombol/bats-assert /tools/bats-assert > /dev/null 2>&1 + git clone --config advice.detachedHead=false --depth 1 --branch v0.2.0 \ + https://github.com/ztombol/bats-file /tools/bats-file > /dev/null 2>&1 + git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \ + https://github.com/ztombol/bats-support /tools/bats-support > /dev/null 2>&1 + bats /opt/stackstorm/st2tests.bat volumes: - - ./st2tests.sh:/st2tests.sh:ro - - tools:/tools + - ./st2tests.bat:/opt/stackstorm/st2tests.bat:ro networks: - st2-docker_private stop_signal: SIGKILL - depends_on: - - st2test-tools - st2test-tools: - image: dduportal/bats:latest - environment: - BATS_HELPERS_DIR: /tools/bats-helpers/ - BATS_DIR: /tools/bats/ - command: /st2tests.sh - volumes: - - tools:/tools - - ./st2tests-tools.sh:/st2tests.sh:ro - -volumes: - tools: networks: st2-docker_private: