From c0860f551cd0a146b19475f589c5bba8ec4e2b76 Mon Sep 17 00:00:00 2001 From: Puskar Basu <45908484+pskrbasu@users.noreply.github.com> Date: Fri, 28 Jul 2023 20:08:12 +0530 Subject: [PATCH] Fix installation.bats tests and increase BATS_TIMEOUT for service tests (#3701) --- .github/workflows/release_cli_and_assets.yml | 170 +++++++++--------- tests/acceptance/test_files/installation.bats | 20 ++- tests/acceptance/test_files/service.bats | 2 +- .../test_files/service_and_plugin.bats | 2 +- 4 files changed, 102 insertions(+), 92 deletions(-) diff --git a/.github/workflows/release_cli_and_assets.yml b/.github/workflows/release_cli_and_assets.yml index 4d6e683f3..10a21752c 100644 --- a/.github/workflows/release_cli_and_assets.yml +++ b/.github/workflows/release_cli_and_assets.yml @@ -496,112 +496,112 @@ jobs: # docker run --name steampipe-oracle `docker images -q sporacle` # echo "docker run complete" - linux_arm_acceptance_tests: - name: Linux ARM64 acceptance tests - needs: [create_test_build,build_and_release_assets] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: true - ref: ${{ github.event.ref }} + # linux_arm_acceptance_tests: + # name: Linux ARM64 acceptance tests + # needs: [create_test_build,build_and_release_assets] + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # with: + # submodules: true + # ref: ${{ github.event.ref }} - - name: Configure AWS Credentials - run: | - mkdir ~/.aws - echo -e "[default]\naws_access_key_id = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }}\naws_secret_access_key = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }}\nregion = ap-south-1" > ~/.aws/credentials + # - name: Configure AWS Credentials + # run: | + # mkdir ~/.aws + # echo -e "[default]\naws_access_key_id = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }}\naws_secret_access_key = ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }}\nregion = ap-south-1" > ~/.aws/credentials - - name: SSH into the EC2 instance and run tests - id: ssh-and-run-test-suite - timeout-minutes: 20 - continue-on-error: true - env: - AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: 'ap-south-1' - PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }} - run: | - # echo $ref - ref=${{ github.event.ref }} + # - name: SSH into the EC2 instance and run tests + # id: ssh-and-run-test-suite + # timeout-minutes: 20 + # continue-on-error: true + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }} + # AWS_DEFAULT_REGION: 'ap-south-1' + # PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }} + # run: | + # # echo $ref + # ref=${{ github.event.ref }} - # get branch - branch=$(echo "$ref" | sed 's/.*\///') + # # get branch + # branch=$(echo "$ref" | sed 's/.*\///') - # get public IP of this runner - ip=$(dig +short myip.opendns.com @resolver1.opendns.com) - echo $ip + # # get public IP of this runner + # ip=$(dig +short myip.opendns.com @resolver1.opendns.com) + # echo $ip - # set PAGER to empty to not get cli output automatically being sent to vim - export PAGER= + # # set PAGER to empty to not get cli output automatically being sent to vim + # export PAGER= - # whitelist the ip, add the ip to the security group to allow access into the instance - aws ec2 authorize-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1 + # # whitelist the ip, add the ip to the security group to allow access into the instance + # aws ec2 authorize-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1 - #start instance - aws ec2 start-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1 --output text - echo "starting instance..." - sleep 60 + # #start instance + # aws ec2 start-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1 --output text + # echo "starting instance..." + # sleep 60 - # get the public ip and status of the instance - public_ip=$(aws ec2 describe-instances --instance-ids i-09b87c86dfdfcd2bd --query 'Reservations[*].Instances[*].PublicDnsName' --region ap-south-1 --output text) - status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text) - echo $public_ip - echo $status + # # get the public ip and status of the instance + # public_ip=$(aws ec2 describe-instances --instance-ids i-09b87c86dfdfcd2bd --query 'Reservations[*].Instances[*].PublicDnsName' --region ap-south-1 --output text) + # status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text) + # echo $public_ip + # echo $status - # check if the instance is available for use, if not, then wait for it - while [ $status != "running" ] ; do - echo "instance not yet available" - sleep 5 - status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text) - done + # # check if the instance is available for use, if not, then wait for it + # while [ $status != "running" ] ; do + # echo "instance not yet available" + # sleep 5 + # status=$(aws ec2 describe-instance-status --instance-ids i-09b87c86dfdfcd2bd --query 'InstanceStatuses[*].InstanceState.Name' --region ap-south-1 --output text) + # done - # set up the private key - echo "$PRIVATE_KEY" > private_key && chmod 600 private_key + # # set up the private key + # echo "$PRIVATE_KEY" > private_key && chmod 600 private_key - #pwd - pwd - chmod +x tests/acceptance/run-linux-arm.sh + # #pwd + # pwd + # chmod +x tests/acceptance/run-linux-arm.sh - # ssh into the instance and run the full acceptance test suite - ssh -o StrictHostKeyChecking=accept-new -i private_key ubuntu@$public_ip 'bash -s' < tests/acceptance/run-linux-arm.sh $branch + # # ssh into the instance and run the full acceptance test suite + # ssh -o StrictHostKeyChecking=accept-new -i private_key ubuntu@$public_ip 'bash -s' < tests/acceptance/run-linux-arm.sh $branch - # success if all tests passed - echo "success" + # # success if all tests passed + # echo "success" - - name: Stop the running instance - if: always() - env: - AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }} - AWS_DEFAULT_REGION: 'ap-south-1' - PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }} - run: | - # get public IP of this runner - ip=$(dig +short myip.opendns.com @resolver1.opendns.com) - echo $ip + # - name: Stop the running instance + # if: always() + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_SECRET_ACCESS_KEY }} + # AWS_DEFAULT_REGION: 'ap-south-1' + # PRIVATE_KEY: ${{ secrets.ACC_TEST_ARM_LINUX_AWS_PRIVATE_KEY }} + # run: | + # # get public IP of this runner + # ip=$(dig +short myip.opendns.com @resolver1.opendns.com) + # echo $ip - # stop instance - aws ec2 stop-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1 + # # stop instance + # aws ec2 stop-instances --instance-ids i-09b87c86dfdfcd2bd --region ap-south-1 - # remove the ip from the security group - aws ec2 revoke-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1 + # # remove the ip from the security group + # aws ec2 revoke-security-group-ingress --group-name pskr-sg --protocol tcp --port 22 --cidr $ip/32 --region ap-south-1 - # fin - echo "fin" + # # fin + # echo "fin" - - name: Check if passed/failed - if: always() - run: | - if [ ${{ steps.ssh-and-run-test-suite.outcome }} == 'success' ]; then - exit 0 - else - exit 1 - fi + # - name: Check if passed/failed + # if: always() + # run: | + # if [ ${{ steps.ssh-and-run-test-suite.outcome }} == 'success' ]; then + # exit 0 + # else + # exit 1 + # fi create_release_tag: name: Tag Release - needs: [run_acceptance_tests,linux_arm_acceptance_tests] + needs: [run_acceptance_tests] runs-on: ubuntu-latest steps: - name: Trim asset version prefix and Validate diff --git a/tests/acceptance/test_files/installation.bats b/tests/acceptance/test_files/installation.bats index 67f0d9c6b..5eee4c8c1 100644 --- a/tests/acceptance/test_files/installation.bats +++ b/tests/acceptance/test_files/installation.bats @@ -10,20 +10,26 @@ load "$LIB_BATS_SUPPORT/load.bash" # check postgres binary is present in correct location run file $target_install_directory/db/14.2.0/postgres/bin/postgres - if [[ "$os" == "Darwin" ]]; then + if [[ "$arch" == "x86_64" && "$os" == "Darwin" ]]; then assert_output --partial 'Mach-O 64-bit executable x86_64' + elif [[ "$arch" == "arm64" && "$os" == "Darwin" ]]; then assert_output --partial 'Mach-O 64-bit executable arm64' - else + elif [[ "$arch" == "x86_64" && "$os" == "Linux" ]]; then assert_output --partial 'ELF 64-bit LSB executable, x86-64' + elif [[ "$arch" == "aarch64" && "$os" == "Linux" ]]; then + assert_output --partial 'ELF 64-bit LSB executable, ARM aarch64' fi # check initdb binary is present in the correct location run file $target_install_directory/db/14.2.0/postgres/bin/initdb - if [[ "$os" == "Darwin" ]]; then - assert_output --partial 'Mach-O 64-bit executable x86_64' + if [[ "$arch" == "arm64" && "$os" == "Darwin" ]]; then assert_output --partial 'Mach-O 64-bit executable arm64' - else + elif [[ "$arch" == "x86_64" && "$os" == "Darwin" ]]; then + assert_output --partial 'Mach-O 64-bit executable x86_64' + elif [[ "$arch" == "x86_64" && "$os" == "Linux" ]]; then assert_output --partial 'ELF 64-bit LSB executable, x86-64' + elif [[ "$arch" == "aarch64" && "$os" == "Linux" ]]; then + assert_output --partial 'ELF 64-bit LSB executable, ARM aarch64' fi # check fdw binary(steampipe_postgres_fdw.so) is present in the correct location @@ -34,6 +40,8 @@ load "$LIB_BATS_SUPPORT/load.bash" assert_output --partial 'Mach-O 64-bit bundle x86_64' elif [[ "$arch" == "x86_64" && "$os" == "Linux" ]]; then assert_output --partial 'ELF 64-bit LSB shared object, x86-64' + elif [[ "$arch" == "aarch64" && "$os" == "Linux" ]]; then + assert_output --partial 'ELF 64-bit LSB shared object, ARM aarch64' fi # check fdw extension(steampipe_postgres_fdw.control) is present in the correct location @@ -59,6 +67,8 @@ load "$LIB_BATS_SUPPORT/load.bash" assert_output --partial 'Mach-O 64-bit executable x86_64' elif [[ "$arch" == "x86_64" && "$os" == "Linux" ]]; then assert_output --partial 'ELF 64-bit LSB executable, x86-64' + elif [[ "$arch" == "aarch64" && "$os" == "Linux" ]]; then + assert_output --partial 'ELF 64-bit LSB executable, ARM aarch64' fi # check spc config file is present in correct location diff --git a/tests/acceptance/test_files/service.bats b/tests/acceptance/test_files/service.bats index 59c5aaa09..90dc84834 100644 --- a/tests/acceptance/test_files/service.bats +++ b/tests/acceptance/test_files/service.bats @@ -237,7 +237,7 @@ load "$LIB_BATS_SUPPORT/load.bash" tar -xf "$zip_location" -C "$tmpdir" # install a couple of plugins which can work with default config - $tmpdir/steampipe --install-dir $tmpdir plugin install chaos net + $tmpdir/steampipe --install-dir $tmpdir plugin install chaos net --progress=false $tmpdir/steampipe --install-dir $tmpdir query "select * from steampipe_internal.steampipe_connection_state" --output json run steampipe --install-dir $tmpdir query "select * from steampipe_internal.steampipe_connection_state" --output json diff --git a/tests/acceptance/test_files/service_and_plugin.bats b/tests/acceptance/test_files/service_and_plugin.bats index c92e3805d..cbbf8e181 100644 --- a/tests/acceptance/test_files/service_and_plugin.bats +++ b/tests/acceptance/test_files/service_and_plugin.bats @@ -783,7 +783,7 @@ load "$LIB_BATS_SUPPORT/load.bash" } function setup_file() { - export BATS_TEST_TIMEOUT=120 + export BATS_TEST_TIMEOUT=180 echo "# setup_file()">&3 }