Skip to content

Commit

Permalink
Update counts so we set default if count is <= 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlaticanin committed Oct 7, 2024
1 parent 3d62123 commit d4c1074
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
2 changes: 2 additions & 0 deletions scale-testing.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
AWS_REGION ?= us-east-2
EKS_K8S_VERSION ?= 1.30

# testing dev instances is currently not supported
# TODO: create the docker registry (e.g. ECR) to enable dev builds
VERSION ?= 0.8.1
INTEGRATION_TESTS_PARALLEL ?= true
SKIP_HCPVSAPPS_TESTS ?= true
Expand Down
14 changes: 10 additions & 4 deletions test/integration/vaultdynamicsecret_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"maps"
"os"
"path"
Expand Down Expand Up @@ -100,13 +101,18 @@ func TestVaultDynamicSecret(t *testing.T) {
// TODO: Extend this to support other dynamic create test cases
defaultCreate := 5 // Default count if no VDS_CREATE_COUNT is set
vdsCreateCount := getEnvInt("VDS_CREATE_COUNT", -1)

// Counts can't be <= 0, if they are, the default count will be used.
if vdsCreateCount <= 0 {
log.Printf("Invalid VDS_CREATE_COUNT: %d, using default count: %d", vdsCreateCount, defaultCreate)
vdsCreateCount = defaultCreate
}

createOnlyCount := getEnvInt("VDS_CREATE_ONLY", defaultCreate)
mixedCount := getEnvInt("VDS_MIXED_CREATE", defaultCreate)

if vdsCreateCount != -1 {
createOnlyCount = vdsCreateCount
mixedCount = vdsCreateCount
}
createOnlyCount = vdsCreateCount
mixedCount = vdsCreateCount

ctx := context.Background()
crdClient := getCRDClient(t)
Expand Down
16 changes: 11 additions & 5 deletions test/integration/vaultpkisecret_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -64,15 +65,20 @@ func TestVaultPKISecret(t *testing.T) {

defaultCreate := 5 // Default count if no VDS_CREATE_COUNT is set
vpsCreateCount := getEnvInt("VPS_CREATE_COUNT", -1)

// Ensure vpsCreateCount is valid
if vpsCreateCount <= 0 {
log.Printf("Invalid VPS_CREATE_COUNT: %d, using default count: %d", vpsCreateCount, defaultCreate)
vpsCreateCount = defaultCreate
}

createOnlyCount := getEnvInt("VPS_CREATE_ONLY", 1)
mixedCount := getEnvInt("VPS_MIXED_CREATE", defaultCreate)
createTLSCount := getEnvInt("VPS_MIXED_CREATE", 2)

if vpsCreateCount != -1 {
createOnlyCount = vpsCreateCount
mixedCount = vpsCreateCount
createTLSCount = vpsCreateCount
}
createOnlyCount = vpsCreateCount
mixedCount = vpsCreateCount
createTLSCount = vpsCreateCount

tempDir, err := os.MkdirTemp(os.TempDir(), t.Name())
require.Nil(t, err)
Expand Down
23 changes: 14 additions & 9 deletions test/integration/vaultstaticsecret_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,29 @@ func TestVaultStaticSecret(t *testing.T) {
// If VSS_CREATE_COUNT is set, it will override the specific test counts.
// If VSS_CREATE_COUNT is not set, the specific test counts will be used.
// If no counts are set, the default count will be used.
// Counts can't be <= 0, if they are, the default count will be used.
defaultCreate := 2 // Default count if no VSS_CREATE_COUNT is set
vssCreateCount := getEnvInt("VSS_CREATE_COUNT", -1)

// Ensure vssCreateCount is valid
if vssCreateCount <= 0 {
log.Printf("Invalid VSS_CREATE_COUNT %d, using default count %d", vssCreateCount, defaultCreate)
vssCreateCount = defaultCreate
}

kvv1Count := getEnvInt("VSS_KVV1_CREATE", defaultCreate)
kvv2Count := getEnvInt("VSS_KVV2_CREATE", defaultCreate)
bothCount := getEnvInt("VSS_BOTH_CREATE", defaultCreate)
kvv2FixedCount := getEnvInt("VSS_KVV2_FIXED_CREATE", defaultCreate)
mixedBothCount := getEnvInt("VSS_MIXED_BOTH_CREATE", defaultCreate)
eventsBothCount := getEnvInt("VSS_EVENTS_BOTH_CREATE", defaultCreate)

// Apply VSS_CREATE_COUNT if it is set
if vssCreateCount != -1 {
kvv1Count = vssCreateCount
kvv2Count = vssCreateCount
bothCount = vssCreateCount
kvv2FixedCount = vssCreateCount
mixedBothCount = vssCreateCount
eventsBothCount = vssCreateCount
}
kvv1Count = vssCreateCount
kvv2Count = vssCreateCount
bothCount = vssCreateCount
kvv2FixedCount = vssCreateCount
mixedBothCount = vssCreateCount
eventsBothCount = vssCreateCount

// The events tests require Vault Enterprise >= 1.16.3, and since that
// changes the app policy required we need to set a flag in the test
Expand Down

0 comments on commit d4c1074

Please sign in to comment.