generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set default for kpk in storage delegation #223
Merged
Merged
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1fc5cac
set default for kpk in storage delegation
Aayush-Abhyarthi 9029960
Merge branch 'main' into use-dft-sd-kpk-name
Aayush-Abhyarthi 838cdca
Merge branch 'main' into use-dft-sd-kpk-name
Aayush-Abhyarthi 362e2d5
add: upgrade test with kms encryption enabled
Aayush-Abhyarthi dc5b6fc
Merge remote-tracking branch 'origin/use-dft-sd-kpk-name' into use-df…
Aayush-Abhyarthi 4f14d53
fix: provider visibility
Aayush-Abhyarthi a67cefc
add: validation and enable encrytion in tests
Aayush-Abhyarthi cb7d23e
do not pass cos_kms_key_crn
Aayush-Abhyarthi 1531c69
fix: pre-commit
Aayush-Abhyarthi 7c2022f
use new project name
Aayush-Abhyarthi 3ba06ee
revert prefix
Aayush-Abhyarthi 66f8459
Merge branch 'main' into use-dft-sd-kpk-name
Aayush-Abhyarthi f0fd1e3
wait 20s to configure project
Aayush-Abhyarthi a870099
Merge remote-tracking branch 'origin/use-dft-sd-kpk-name' into use-df…
Aayush-Abhyarthi c386f71
fix: cra-scan
Aayush-Abhyarthi ec44fc1
revert configure project time
Aayush-Abhyarthi 4ea7c5e
revert configure project time
Aayush-Abhyarthi b768045
trigger test
Aayush-Abhyarthi 01fdf53
SKIP UPGRADE TEST
Aayush-Abhyarthi 84e7419
Merge branch 'main' into use-dft-sd-kpk-name
Aayush-Abhyarthi 47a6ba8
resolve conflicts
Aayush-Abhyarthi a7c6bfb
UNSKIP UPGRADE TEST
Aayush-Abhyarthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule common-dev-assets
updated
2 files
+1 −1 | examples/Dockerfile | |
+1 −1 | module-assets/ci/install-deps.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,3 +178,87 @@ func TestWithExistingKP(t *testing.T) { | |
} | ||
|
||
} | ||
|
||
func TestRunUpgradeExistingKP(t *testing.T) { | ||
t.Parallel() | ||
|
||
// ------------------------------------------------------------------------------------ | ||
// Provision KP first | ||
// ------------------------------------------------------------------------------------ | ||
|
||
prefix := fmt.Sprintf("kp-ut-%s", strings.ToLower(random.UniqueId())) | ||
realTerraformDir := "./resources/kp-instance" | ||
tempTerraformDir, _ := files.CopyTerraformFolderToTemp(realTerraformDir, fmt.Sprintf(prefix+"-%s", strings.ToLower(random.UniqueId()))) | ||
region := "us-south" | ||
|
||
// Verify ibmcloud_api_key variable is set | ||
checkVariable := "TF_VAR_ibmcloud_api_key" | ||
val, present := os.LookupEnv(checkVariable) | ||
require.True(t, present, checkVariable+" environment variable not set") | ||
require.NotEqual(t, "", val, checkVariable+" environment variable is empty") | ||
|
||
logger.Log(t, "Tempdir: ", tempTerraformDir) | ||
existingTerraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{ | ||
TerraformDir: tempTerraformDir, | ||
Vars: map[string]interface{}{ | ||
"prefix": prefix, | ||
"region": region, | ||
}, | ||
// Set Upgrade to true to ensure latest version of providers and modules are used by terratest. | ||
// This is the same as setting the -upgrade=true flag with terraform. | ||
Upgrade: true, | ||
}) | ||
|
||
terraform.WorkspaceSelectOrNew(t, existingTerraformOptions, prefix) | ||
_, existErr := terraform.InitAndApplyE(t, existingTerraformOptions) | ||
if existErr != nil { | ||
assert.True(t, existErr == nil, "Init and Apply of temp existing resource failed") | ||
} else { | ||
|
||
// ------------------------------------------------------------------------------------ | ||
// Upgrade test for watsonx DA passing in existing KP details | ||
// ------------------------------------------------------------------------------------ | ||
|
||
options := testhelper.TestOptionsDefault(&testhelper.TestOptions{ | ||
Testing: t, | ||
TerraformDir: rootDaDir, | ||
Prefix: "existing-kp-upg", | ||
IgnoreDestroys: testhelper.Exemptions{ // Ignore for consistency check | ||
List: []string{ | ||
"module.configure_user.null_resource.configure_user", | ||
"module.configure_user.null_resource.restrict_access", | ||
}, | ||
}, | ||
IgnoreUpdates: testhelper.Exemptions{ // Ignore for consistency check | ||
List: []string{ | ||
"module.configure_user.null_resource.configure_user", | ||
"module.configure_user.null_resource.restrict_access", | ||
}, | ||
}, | ||
TerraformVars: map[string]interface{}{ | ||
"location": validRegions[rand.Intn(len(validRegions))], | ||
"resource_group_name": prefix, | ||
"provider_visibility": "public", | ||
"cos_kms_crn": terraform.Output(t, existingTerraformOptions, "key_protect_crn"), | ||
"cos_kms_key_crn": terraform.Output(t, existingTerraformOptions, "kms_key_crn"), | ||
}, | ||
}) | ||
|
||
output, err := options.RunTestUpgrade() | ||
assert.Nil(t, err, "This should not have errored") | ||
assert.NotNil(t, output, "Expected some output") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated to:
|
||
} | ||
|
||
// Check if "DO_NOT_DESTROY_ON_FAILURE" is set | ||
envVal, _ := os.LookupEnv("DO_NOT_DESTROY_ON_FAILURE") | ||
// Destroy the temporary existing resources if required | ||
if t.Failed() && strings.ToLower(envVal) == "true" { | ||
fmt.Println("Terratest failed. Debug the test and delete resources manually.") | ||
} else { | ||
logger.Log(t, "START: Destroy (existing resources)") | ||
terraform.Destroy(t, existingTerraformOptions) | ||
terraform.WorkspaceDelete(t, existingTerraformOptions, prefix) | ||
logger.Log(t, "END: Destroy (existing resources)") | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To enable encryption, you need to set
enable_cos_kms_encryption = true
. The fact that the test passed even when passing values forcos_kms_crn
andcos_kms_key_crn
makes me think we should add variable validation to the DA code to ensure that if user does pass values for these, thatenable_cos_kms_encryption
has to be set to trueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also looks like
TestWithExistingKP
also needs this updateThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocofaigh Added
enable_cos_kms_encryption = true
, still the test passed.