diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index c10ca829..3b61e590 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -54,7 +54,7 @@ jobs: - name: 'Run integration tests' env: - TEST_JVS_INTEGRATION: 'true' + TEST_INTEGRATION: 'true' TEST_JVS_KMS_KEY_RING: 'projects/${{ env.PROJECT_ID }}/locations/global/keyRings/ci-keyring' run: |- go test \ diff --git a/go.mod b/go.mod index 2901ae07..6ef5dfa9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( cloud.google.com/go/kms v1.4.0 - github.com/abcxyz/pkg v0.0.0-20221010190357-4e20e092316a + github.com/abcxyz/pkg v0.1.2-0.20230106203017-d05e75ed64fa github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.9 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index b07dcb91..1c6f3b6c 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/abcxyz/pkg v0.0.0-20221010190357-4e20e092316a h1:qibheUlonMxv3rMhBnarccQiUwiZivW8TUQiNn4+aG4= -github.com/abcxyz/pkg v0.0.0-20221010190357-4e20e092316a/go.mod h1:vzO7x3uKaRbxbCCrQZvgxrglkVhMbf/1FlDgU/DJoxA= +github.com/abcxyz/pkg v0.1.2-0.20230106203017-d05e75ed64fa h1:RfAkfbvZ+LOIwTgfyDV4vi3wiVCNDqvtI2FroCQ6QDI= +github.com/abcxyz/pkg v0.1.2-0.20230106203017-d05e75ed64fa/go.mod h1:vzO7x3uKaRbxbCCrQZvgxrglkVhMbf/1FlDgU/DJoxA= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/test/integ/main_test.go b/test/integ/main_test.go index 3935fe2a..05543583 100644 --- a/test/integ/main_test.go +++ b/test/integ/main_test.go @@ -58,15 +58,9 @@ import ( func TestJVS(t *testing.T) { t.Parallel() - - if !testIsIntegration(t) { - // Not an integ test, don't run anything. - t.Skip("Not an integration test, skipping...") - return - } + testutil.SkipIfNotIntegration(t) ctx := context.Background() - keyRing := os.Getenv("TEST_JVS_KMS_KEY_RING") if keyRing == "" { t.Fatal("Key ring must be provided using TEST_JVS_KMS_KEY_RING env variable.") @@ -310,13 +304,9 @@ func TestJVS(t *testing.T) { //nolint:tparallel func TestRotator(t *testing.T) { t.Parallel() - ctx := context.Background() - if !testIsIntegration(t) { - // Not an integ test, don't run anything. - t.Skip("Not an integration test, skipping...") - return - } + testutil.SkipIfNotIntegration(t) + ctx := context.Background() kmsClient, keyName := testSetupRotator(ctx, t) cfg := &config.CryptoConfig{ @@ -401,13 +391,9 @@ func TestRotator(t *testing.T) { //nolint:tparallel // Subtests need to run in sequence. To parallelize this, but we'd need separate keys from the above (more cruft). func TestRotator_EdgeCases(t *testing.T) { t.Parallel() - ctx := context.Background() - if !testIsIntegration(t) { - // Not an integ test, don't run anything. - t.Skip("Not an integration test, skipping...") - return - } + testutil.SkipIfNotIntegration(t) + ctx := context.Background() kmsClient, keyName := testSetupRotator(ctx, t) cfg := &config.CryptoConfig{ @@ -463,13 +449,9 @@ func TestRotator_EdgeCases(t *testing.T) { func TestPublicKeys(t *testing.T) { t.Parallel() - ctx := context.Background() - if !testIsIntegration(t) { - // Not an integ test, don't run anything. - t.Skip("Not an integration test, skipping...") - return - } + testutil.SkipIfNotIntegration(t) + ctx := context.Background() kmsClient, err := kms.NewKeyManagementClient(ctx) if err != nil { t.Fatalf("failed to setup kms client: %s", err) @@ -529,13 +511,9 @@ func TestPublicKeys(t *testing.T) { //nolint:tparallel func TestCertActions(t *testing.T) { t.Parallel() - ctx := context.Background() - if !testIsIntegration(t) { - // Not an integ test, don't run anything. - t.Skip("Not an integration test, skipping...") - return - } + testutil.SkipIfNotIntegration(t) + ctx := context.Background() kmsClient, keyName := testSetupRotator(ctx, t) cfg := &config.CryptoConfig{ @@ -786,19 +764,6 @@ func testValidateKeyVersionState(ctx context.Context, tb testing.TB, kmsClient * } } -func testIsIntegration(tb testing.TB) bool { - tb.Helper() - integVal := os.Getenv("TEST_JVS_INTEGRATION") - if integVal == "" { - return false - } - isInteg, err := strconv.ParseBool(integVal) - if err != nil { - tb.Fatalf("Unable to parse TEST_JVS_INTEGRATION flag %s: %s", integVal, err) - } - return isInteg -} - // Create an asymmetric signing key for use with integration tests. func testCreateKey(ctx context.Context, tb testing.TB, kmsClient *kms.KeyManagementClient, keyRing, primaryKeyVersion string) string { tb.Helper()