-
Notifications
You must be signed in to change notification settings - Fork 123
CSPL-949: Refactor of secret test cases #298
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,7 +282,8 @@ jobs: | |
mkdir -p /tmp/test-results | ||
find ./test -name "*junit.xml" -exec cp {} /tmp/test-results \; | ||
environment: | ||
TEST_FOCUS: "smoke|ingest_search|monitoring_console|smartstore|licensemaster|scaling_test|crcrud|secret" | ||
# TEST_FOCUS: "smoke|ingest_search|monitoring_console|smartstore|licensemaster|scaling_test|crcrud|secret" | ||
TEST_FOCUS: "integration" | ||
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. Are we able to control which tests we can run with this change? 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. Yes we are coming up with keyword to define different test and this is a change in that direction. We should be able to run different test based on keyword. |
||
- store_test_results: | ||
name: Save test results | ||
path: /tmp/test-results | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Copyright (c) 2018-2021 Splunk Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package secret | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
splcommon "github.com/splunk/splunk-operator/pkg/splunk/common" | ||
"github.com/splunk/splunk-operator/test/testenv" | ||
) | ||
|
||
var _ = Describe("Secret Test for SVA C3", func() { | ||
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. As discussed, it would be prudent to think of the overall hierarchy of the testing source code taking into consideration features, utilities, SVA's etc to optimize the number of lines of code, reduce complexity and achieve maximum code readability. If already discussed, please ignore. 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 change is in that direction. |
||
|
||
var deployment *testenv.Deployment | ||
|
||
BeforeEach(func() { | ||
var err error | ||
deployment, err = testenvInstance.NewDeployment(testenv.RandomDNSName(3)) | ||
Expect(err).To(Succeed(), "Unable to create deployment") | ||
}) | ||
|
||
AfterEach(func() { | ||
// When a test spec failed, skip the teardown so we can troubleshoot. | ||
if CurrentGinkgoTestDescription().Failed { | ||
testenvInstance.SkipTeardown = true | ||
} | ||
if deployment != nil { | ||
deployment.Teardown() | ||
} | ||
}) | ||
|
||
Context("Clustered deployment (C3 - clustered indexer, search head cluster)", func() { | ||
It("secret: secret update on indexers and search head cluster", func() { | ||
|
||
/* Test Scenario | ||
pdhanoya-splunk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
1. Update Secrets Data | ||
2. Verify New versioned secret are created with correct value. | ||
3. Verify new secrets are mounted on pods. | ||
4. Verify New Secrets are present in server.conf (Pass4SymmKey) */ | ||
|
||
// Download License File | ||
licenseFilePath, err := testenv.DownloadFromS3Bucket() | ||
Expect(err).To(Succeed(), "Unable to download license file") | ||
|
||
// Create License Config Map | ||
testenvInstance.CreateLicenseConfigMap(licenseFilePath) | ||
|
||
err = deployment.DeploySingleSiteCluster(deployment.GetName(), 3, true) | ||
Expect(err).To(Succeed(), "Unable to deploy cluster") | ||
|
||
// Wait for License Master to be in READY status | ||
testenv.LicenseMasterReady(deployment, testenvInstance) | ||
|
||
// Ensure that the cluster-master goes to Ready phase | ||
testenv.ClusterMasterReady(deployment, testenvInstance) | ||
|
||
// Ensure indexers go to Ready phase | ||
testenv.SingleSiteIndexersReady(deployment, testenvInstance) | ||
|
||
// Ensure search head cluster go to Ready phase | ||
testenv.SearchHeadClusterReady(deployment, testenvInstance) | ||
|
||
// Verify MC Pod is Ready | ||
testenv.MCPodReady(testenvInstance.GetName(), deployment) | ||
|
||
// Verify RF SF is met | ||
testenv.VerifyRFSFMet(deployment, testenvInstance) | ||
|
||
// Get Current Secrets Struct | ||
namespaceScopedSecretName := fmt.Sprintf(testenv.NamespaceScopedSecretObjectName, testenvInstance.GetName()) | ||
secretStruct, err := testenv.GetSecretStruct(deployment, testenvInstance.GetName(), namespaceScopedSecretName) | ||
Expect(err).To(Succeed(), "Unable to get secret struct") | ||
|
||
// Update Secret Value on Secret Object | ||
testenvInstance.Log.Info("Data in secret object", "data", secretStruct.Data) | ||
modifiedHecToken := testenv.GetRandomeHECToken() | ||
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. We already have APIs: generateHECToken - Generating a 36 byte HEC token Not necessary to use them, but we can maintain uniformity if we re-use them. 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. generateHECToken is not callable outside of that file. So I had to create a new method. |
||
modifedValue := testenv.RandomDNSName(10) | ||
updatedSecretData := testenv.GetSecretDataMap(modifiedHecToken, modifedValue, modifedValue, modifedValue, modifedValue) | ||
|
||
err = testenv.ModifySecretObject(deployment, testenvInstance.GetName(), namespaceScopedSecretName, updatedSecretData) | ||
Expect(err).To(Succeed(), "Unable to update secret Object") | ||
|
||
// Ensure that Cluster Master goes to update phase | ||
testenv.VerifyClusterMasterPhase(deployment, testenvInstance, splcommon.PhaseUpdating) | ||
|
||
// Wait for License Master to be in READY status | ||
testenv.LicenseMasterReady(deployment, testenvInstance) | ||
|
||
// Ensure that the cluster-master goes to Ready phase | ||
testenv.ClusterMasterReady(deployment, testenvInstance) | ||
|
||
// Ensure indexers go to Ready phase | ||
testenv.SingleSiteIndexersReady(deployment, testenvInstance) | ||
|
||
// Ensure search head cluster go to Ready phase | ||
testenv.SearchHeadClusterReady(deployment, testenvInstance) | ||
|
||
// Verify MC Pod is Ready | ||
testenv.MCPodReady(testenvInstance.GetName(), deployment) | ||
|
||
// Verify RF SF is met | ||
testenv.VerifyRFSFMet(deployment, testenvInstance) | ||
|
||
// Once Pods are READY check each versioned secret for updated secret keys | ||
secretObjectNames := testenv.GetVersionedSecretNames(testenvInstance.GetName(), 2) | ||
|
||
// Verify Secrets on versioned secret objects | ||
testenv.VerifySecretsOnSecretObjects(deployment, testenvInstance, secretObjectNames, updatedSecretData, true) | ||
|
||
// Once Pods are READY check each pod for updated secret keys | ||
verificationPods := testenv.DumpGetPods(testenvInstance.GetName()) | ||
|
||
// Verify secrets on pods | ||
testenv.VerifySecretsOnPods(deployment, testenvInstance, verificationPods, updatedSecretData, true) | ||
|
||
// Verify Pass4SymmKey Secrets on ServerConf on MC, LM Pods | ||
testenv.VerifySplunkServerConfSecrets(deployment, testenvInstance, verificationPods, updatedSecretData, true) | ||
|
||
}) | ||
}) | ||
}) |
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.
Do we need the commented out line?
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.
This is just for reference I will remove it in future.