From 0cec4fb6a1ad3c9635d40b5ae267bdc7b0a1892b Mon Sep 17 00:00:00 2001 From: JM Faircloth Date: Thu, 17 Oct 2024 10:32:28 -0500 Subject: [PATCH] add more debug and use t.Cleanup --- .github/workflows/build.yml | 78 ------------------- testutil/postgresqlhelper.go | 7 +- ...atabase_secret_backend_static_role_test.go | 6 +- 3 files changed, 7 insertions(+), 84 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 103107e02..c6eb606cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -63,12 +63,7 @@ jobs: fail-fast: false matrix: image: - - "vault-enterprise:1.14.13-ent" - - "vault-enterprise:1.15.16-ent" - - "vault-enterprise:1.16.11-ent" - - "vault-enterprise:1.17.7-ent" - "vault-enterprise:1.18.0-ent" - - "vault:latest" services: vault: image: hashicorp/${{ matrix.image }} @@ -87,27 +82,6 @@ jobs: - 8200:8200 volumes: - ${{ github.workspace }}:/vault/plugins - mysql: - image: docker.mirror.hashicorp.services/mysql:latest - env: - MYSQL_ROOT_PASSWORD: mysql - ports: - - 3306:3306 - mssql: - image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu - env: - ACCEPT_EULA: Y - SA_PASSWORD: ${{ secrets.MSSQL_SA_PASSWORD }} - ports: - - 1433:1433 - mongo: - image: docker.mirror.hashicorp.services/mongo:latest - env: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: mongodb - MONGO_INITDB_DATABASE: admin - ports: - - 27017:27017 postgres: image: docker.mirror.hashicorp.services/postgres:latest env: @@ -115,46 +89,6 @@ jobs: POSTGRES_DB: database ports: - 5432:5432 - couchbase: - image: docker.io/couchbase/server-sandbox:7.1.1 - ports: - - 8091:8091 - - 8092:8092 - - 8093:8093 - - 8094:8094 - - 11207:11207 - - 11210:11210 - - 18091:18091 - - 18092:18092 - - 18093:18093 - - 18094:18094 - options: >- - --health-cmd "curl -f http://Administrator:password@127.0.0.1:8091/sampleBuckets" - --health-interval 1s - --health-timeout 5s - --health-retries 60 - consul: - image: docker.mirror.hashicorp.services/hashicorp/consul:latest - env: - CONSUL_LOCAL_CONFIG: "{\"acl\":{\"enabled\":true}}" - ports: - - 8500:8500 - - 8600:8600 - options: >- - --health-cmd "curl -f 'http://127.0.0.1:8500/v1/health/node/server-1'" - --health-interval 1s - --health-timeout 5s - --health-retries 5 - openldap: - image: docker.io/bitnami/openldap:2.6 - ports: - - 1389:1389 - - 1636:1636 - env: - LDAP_ADMIN_USERNAME: "admin" - LDAP_ADMIN_PASSWORD: "adminpassword" - LDAP_USERS: "alice,bob,foo" - LDAP_PASSWORDS: "password1,password2,password3" steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 @@ -169,18 +103,6 @@ jobs: terraform_wrapper: false - name: Check Terraform CLI version run: terraform --version - - name: Download external plugin - id: plugin - env: - PLUGIN: "vault-plugin-auth-jwt" - VERSION: "0.17.0" - run: | - ZIP="${PLUGIN}_${VERSION}_linux_amd64.zip" - SHA256SUMS="${PLUGIN}_${VERSION}_SHA256SUMS" - curl -sO "https://releases.hashicorp.com/${PLUGIN}/${VERSION}/{${ZIP},${SHA256SUMS}}" - shasum -a 256 -c "${PLUGIN}_${VERSION}_SHA256SUMS" --ignore-missing - unzip "${ZIP}"; rm "${ZIP}" "${SHA256SUMS}" - echo "command=${PLUGIN}" >> "${GITHUB_OUTPUT}" - name: Cache go build uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/testutil/postgresqlhelper.go b/testutil/postgresqlhelper.go index 6a5312897..9b09e968f 100644 --- a/testutil/postgresqlhelper.go +++ b/testutil/postgresqlhelper.go @@ -7,12 +7,13 @@ import ( "context" "database/sql" "fmt" - "github.com/hashicorp/vault/sdk/helper/dbtxn" - "github.com/hashicorp/vault/sdk/helper/docker" "net/url" "os" "testing" + "github.com/hashicorp/vault/sdk/helper/dbtxn" + "github.com/hashicorp/vault/sdk/helper/docker" + _ "github.com/jackc/pgx/v4/stdlib" ) @@ -44,7 +45,7 @@ func defaultRunOpts(t *testing.T) docker.RunOptions { func CreateTestPGUser(t *testing.T, connURL string, username, password, query string) { t.Helper() - t.Logf("[TRACE] Creating test user") + t.Logf("[TRACE] Creating test user %q, password %q", username, password) db, err := sql.Open("pgx", connURL) defer db.Close() diff --git a/vault/resource_database_secret_backend_static_role_test.go b/vault/resource_database_secret_backend_static_role_test.go index 5fb8377bd..f83f3c975 100644 --- a/vault/resource_database_secret_backend_static_role_test.go +++ b/vault/resource_database_secret_backend_static_role_test.go @@ -165,11 +165,11 @@ CREATE ROLE "{{name}}" WITH ` cleanup, pgxURL := testutil.PrepareTestContainerSelfManaged(t) - fmt.Println("pgxURL", pgxURL) - defer cleanup() + t.Logf("pgxURL", pgxURL) + t.Cleanup(cleanup()) connURL := fmt.Sprintf("postgresql://{{username}}:{{password}}@%s/postgres?sslmode=disable", pgxURL.Host) - fmt.Println("connURL ", connURL) + t.Logf("connURL ", connURL) // create static database user testutil.CreateTestPGUser(t, pgxURL.String(), username, "testpassword", testRoleStaticCreate)