From 2c6b1593d63e96af8d0bd6650308ecbb6756bd8d Mon Sep 17 00:00:00 2001 From: jandroav Date: Mon, 2 Oct 2023 13:32:15 +0200 Subject: [PATCH] fix(aws.yml): remove unnecessary steps for getting LocalStack DB secrets feat(aws.yml): add support for creating Aurora MySQL and Aurora Postgresql databases in LocalStack for testing purposes fix(aws.yml): fix typo in retrieving Aurora Postgresql port fix(aws.yml): update Maven command to use hardcoded dbUsername and dbPassword for Aurora MySQL test run fix(aws.yml): update Maven command to use hardcoded dbUsername and dbPassword for Aurora Postgresql test run fix(.project): add filter to exclude unnecessary resources from project feat(localstack/main.tf): remove unnecessary Terraform configuration file --- .github/workflows/aws.yml | 32 +++++++++++++++++--------------- .project | 11 +++++++++++ localstack/main.tf | 27 --------------------------- 3 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 localstack/main.tf diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml index 6ba2244da..e799a8a11 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflows/aws.yml @@ -81,18 +81,6 @@ jobs: echo "Waiting for LocalStack startup..." localstack wait -t 30 echo "Startup complete" - cd ./localstack && tflocal init && tflocal apply -auto-approve - - - name: Get LocalStack DB secrets - run: | - username=$(awslocal secretsmanager get-secret-value --secret-id /testautomation/db_details/th_dbs_username --query SecretString --output text) - password=$(awslocal secretsmanager get-secret-value --secret-id /testautomation/db_details/th_dbs_password --query SecretString --output text) - aurora_mysql_jdbc_url=$(awslocal secretsmanager get-secret-value --secret-id /testautomation/db_details/aurora_mysql_jdbc --query SecretString --output text) - aurora_postgresql_jdbc_url=$(awslocal secretsmanager get-secret-value --secret-id /testautomation/db_details/aurora_postgresql_jdbc --query SecretString --output text) - echo "TH_DB_ADMIN=$username" >> $GITHUB_ENV - echo "TH_DB_PASSWD=$password" >> $GITHUB_ENV - echo "TH_AURORA_MYSQLURL=$aurora_mysql_jdbc_url" >> $GITHUB_ENV - echo "TH_AURORA_POSTGRESQLURL=$aurora_postgresql_jdbc_url" >> $GITHUB_ENV - name: Configure Test id: setup @@ -102,14 +90,28 @@ jobs: let splitValues = "${{ matrix.database }}".split(":") core.setOutput("databasePlatform", splitValues[0]); core.setOutput("databaseVersion", splitValues[1]); + echo "TH_DB_ADMIN=lbuser" >> $GITHUB_ENV + echo "TH_DB_PASSWD=test" >> $GITHUB_ENV + - name: Init Aurora MySQL Database if: ${{ steps.setup.outputs.databasePlatform == 'mysql' && steps.setup.outputs.databaseVersion == 'aurora' }} - run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ steps.setup.outputs.databasePlatform }}.sql" --username="root" --password="${{ env.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_MYSQLURL }}" update + run: | + awslocal rds create-db-cluster --db-cluster-identifier aurora-mysql-primary-cluster --engine aurora-mysql --engine-version 8.0 --database-name lbcat --master-username lbuser --master-user-password test + awslocal rds create-db-instance --db-instance-identifier aurora-mysql-primary-cluster-instance --db-cluster-identifier aurora-mysql-primary-cluster --engine aurora-mysql --db-instance-class db.t3.medium + aurora_mysql_port=$(awslocal rds describe-db-instances --db-instance-identifier aurora-mysql-primary-cluster-instance --query 'DBInstances[0].Endpoint.Port' | jq -r) + aurora_mysql_url="jdbc:mysql://localhost:$aurora_mysql_port/lbcat" + echo "TH_AURORA_MYSQLURL=$aurora_mysql_url" >> $GITHUB_ENV + liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ steps.setup.outputs.databasePlatform }}.sql" --username="root" --password="${{ env.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_MYSQLURL }}" update - name: Init Aurora Postgresql Database if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion == 'aurora' }} - run: liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ steps.setup.outputs.databasePlatform }}.sql" --username="${{ env.TH_DB_ADMIN }}" --password="${{ env.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_POSTGRESQLURL }}" update + run: | + awslocal rds create-db-cluster --db-cluster-identifier aurora-postgresql-primary-cluster --engine aurora-postgresql --engine-version 14.5 --database-name lbcat --master-username lbuser --master-user-password test + awslocal rds create-db-instance --db-instance-identifier aurora-postgresql-primary-cluster-instance --db-cluster-identifier aurora-postgresql-primary-cluster --engine aurora-postgresql --db-instance-class db.t3.medium + aurora_postgresql_port=$(awslocal rds describe-db-instances --db-instance-identifier aurora-mysql-primary-cluster-instance --query 'DBInstances[0].Endpoint.Port' | jq -r) + echo "TH_AURORA_POSTGRESQLURL=$aurora_postgresql_port" >> $GITHUB_ENV + liquibase --classpath="src/test/resources/init-changelogs/aws" --changeLogFile="${{ steps.setup.outputs.databasePlatform }}.sql" --username="${{ env.TH_DB_ADMIN }}" --password="${{ env.TH_DB_PASSWD }}" --url="${{ env.TH_AURORA_POSTGRESQLURL }}" update - uses: liquibase-github-actions/drop-all@v4.23.2 if: ${{ steps.setup.outputs.databasePlatform == 'oracle' }} @@ -215,7 +217,7 @@ jobs: if: ${{ steps.setup.outputs.databasePlatform == 'mysql' && steps.setup.outputs.databaseVersion == 'aurora' }} env: LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.LICENSE_KEY }} - run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -DdbUsername=${{ env.TH_DB_ADMIN }} -DdbPassword=${{ env.TH_DB_PASSWD }} -DdbUrl='${{ env.TH_AURORA_MYSQLURL }}' test + run: mvn -Dtest=${{ needs.setup.outputs.testClasses }} -DconfigFile=/harness-config-cloud.yml -DdbName=${{ steps.setup.outputs.databasePlatform }} -DdbVersion=${{ steps.setup.outputs.databaseVersion }} -DdbUsername=lbuser -DdbPassword=test -DdbUrl='${{ env.TH_AURORA_MYSQLURL }}' test - name: AWS Aurora ${{ steps.setup.outputs.databasePlatform }} Test Run if: ${{ steps.setup.outputs.databasePlatform == 'postgresql' && steps.setup.outputs.databaseVersion == 'aurora' }} diff --git a/.project b/.project index dd3c42e39..85c2be4b6 100644 --- a/.project +++ b/.project @@ -21,4 +21,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + 1695897288323 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/localstack/main.tf b/localstack/main.tf deleted file mode 100644 index dcbbfe7f2..000000000 --- a/localstack/main.tf +++ /dev/null @@ -1,27 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "5.17.0" - } - random = { - source = "hashicorp/random" - version = "3.3.1" - } - } -} - -provider "aws" { - region = "us-east-1" -} - -provider "github" { - owner = "liquibase" -} - -module "test-automation" { - source = "app.terraform.io/liquibase/test-automation/aws" - version = "0.1.0" - create_aurora_mysql = true - create_aurora_postgres = true -} \ No newline at end of file