Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

TEST_FOCUS: "integration"
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
2 changes: 1 addition & 1 deletion test/custom_resource_crud/custom_resource_crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var _ = Describe("crcrud test", func() {
})

Context("Clustered deployment (C3 - clustered indexer, search head cluster)", func() {
It("crcrud: can deploy indexer and search head cluster, change their CR, update the instances", func() {
It("integration, crcrud: can deploy indexer and search head cluster, change their CR, update the instances", func() {

// Deploy Single site Cluster and Search Head Clusters
err := deployment.DeploySingleSiteCluster(deployment.GetName(), 3, true /*shc*/)
Expand Down
4 changes: 2 additions & 2 deletions test/ingest_search/ingest_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var _ = Describe("Ingest and Search Test", func() {
})

Context("Standalone deployment (S1)", func() {
It("ingest_search: can search internal logs for standalone instance", func() {
It("ingest_search, integration: can search internal logs for standalone instance", func() {

standalone, err := deployment.DeployStandalone(deployment.GetName())
Expect(err).To(Succeed(), "Unable to deploy standalone instance ")
Expand Down Expand Up @@ -127,7 +127,7 @@ var _ = Describe("Ingest and Search Test", func() {
})

Context("Standalone deployment (S1)", func() {
It("ingest_search: can ingest custom data to new index and search", func() {
It("ingest_search, integration: can ingest custom data to new index and search", func() {

standalone, err := deployment.DeployStandalone(deployment.GetName())
Expect(err).To(Succeed(), "Unable to deploy standalone instance ")
Expand Down
83 changes: 4 additions & 79 deletions test/licensemaster/lm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("Licensemaster test", func() {
})

Context("Clustered deployment (C3 - clustered indexer, search head cluster)", func() {
It("licensemaster: can deploy indexers and search head cluster", func() {
It("licensemaster, integration: Splunk Operator can configure License Master with Indexers and Search Heads in C3 SVA", func() {

// Download License File
licenseFilePath, err := testenv.DownloadFromS3Bucket()
Expand Down Expand Up @@ -88,8 +88,8 @@ var _ = Describe("Licensemaster test", func() {
})
})

Context("Multisite cluster deployment (M13 - Multisite indexer cluster, Search head cluster)", func() {
It("licensemaster: can deploy indexers and search head cluster", func() {
Context("Multisite cluster deployment (M4 - Multisite indexer cluster, Search head cluster)", func() {
It("licensemaster: Splunk Operator can configure license master with indexers and search head in M4 SVA", func() {

// Download License File
licenseFilePath, err := testenv.DownloadFromS3Bucket()
Expand Down Expand Up @@ -138,47 +138,8 @@ var _ = Describe("Licensemaster test", func() {
})
})

Context("Multisite cluster deployment (M1 - multisite indexer cluster)", func() {
It("licensemaster: can deploy multisite indexers cluster", func() {

// Download License File
licenseFilePath, err := testenv.DownloadFromS3Bucket()
Expect(err).To(Succeed(), "Unable to download license file")

// Create License Config Map
testenvInstance.CreateLicenseConfigMap(licenseFilePath)

siteCount := 3
err = deployment.DeployMultisiteCluster(deployment.GetName(), 1, siteCount)
Expect(err).To(Succeed(), "Unable to deploy cluster")

// Ensure that the cluster-master goes to Ready phase
testenv.ClusterMasterReady(deployment, testenvInstance)

// Ensure the indexers of all sites go to Ready phase
testenv.IndexersReady(deployment, testenvInstance, siteCount)

// Ensure cluster configured as multisite
testenv.IndexerClusterMultisiteStatus(deployment, testenvInstance, siteCount)

// Verify MC Pod is Ready
testenv.MCPodReady(testenvInstance.GetName(), deployment)

// Verify RF SF is met
testenv.VerifyRFSFMet(deployment, testenvInstance)

// Verify LM is configured on indexers
indexerPodName := fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, 0)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
indexerPodName = fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), 2, 0)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
indexerPodName = fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), 3, 0)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
})
})

Context("Standalone deployment (S1) with LM", func() {
It("licensemaster: can deploy a standalone instance and a License Master", func() {
It("licensemaster: Splunk Operator can configure License Master with Standalone in S1 SVA", func() {

// Download License File
licenseFilePath, err := testenv.DownloadFromS3Bucket()
Expand All @@ -205,40 +166,4 @@ var _ = Describe("Licensemaster test", func() {
testenv.VerifyLMConfiguredOnPod(deployment, standalonePodName)
})
})

Context("Clustered deployment (C3 - clustered indexer) with LM", func() {
It("licensemaster: can deploy indexer cluster with LM", func() {

// Download License File
licenseFilePath, err := testenv.DownloadFromS3Bucket()
Expect(err).To(Succeed(), "Unable to download license file")

// Create License Config Map
testenvInstance.CreateLicenseConfigMap(licenseFilePath)

// Create Cluster Master with LicenseMasterRef, IndexerCluster without LicenseMasterRef
err = deployment.DeploySingleSiteCluster(deployment.GetName(), 3, true /*shc*/)
Expect(err).To(Succeed(), "Unable to deploy cluster")

// Ensure that the cluster-master goes to Ready phase
testenv.ClusterMasterReady(deployment, testenvInstance)

// Ensure indexers go to Ready phase
testenv.SingleSiteIndexersReady(deployment, testenvInstance)

// Verify MC Pod is Ready
testenv.MCPodReady(testenvInstance.GetName(), deployment)

// Verify RF SF is met
testenv.VerifyRFSFMet(deployment, testenvInstance)

// Verify LM is configured on indexers
indexerPodName := fmt.Sprintf(testenv.IndexerPod, deployment.GetName(), 0)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
indexerPodName = fmt.Sprintf(testenv.IndexerPod, deployment.GetName(), 1)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
indexerPodName = fmt.Sprintf(testenv.IndexerPod, deployment.GetName(), 2)
testenv.VerifyLMConfiguredOnPod(deployment, indexerPodName)
})
})
})
4 changes: 2 additions & 2 deletions test/monitoring_console/monitoring_console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var _ = Describe("Monitoring Console test", func() {
})

Context("Standalone deployment (S1)", func() {
It("monitoring_console: can deploy a MC with standalone instance and update MC with new standalone deployment", func() {
It("monitoring_console, integration: can deploy a MC with standalone instance and update MC with new standalone deployment", func() {

standaloneOneName := deployment.GetName()
standaloneOne, err := deployment.DeployStandalone(standaloneOneName)
Expand Down Expand Up @@ -203,7 +203,7 @@ var _ = Describe("Monitoring Console test", func() {
})

Context("Clustered deployment (C3 - clustered indexer, search head cluster)", func() {
It("monitoring_console: MC can configure SHC, indexer instances after scale up and standalone in a namespace", func() {
It("monitoring_console, integration: MC can configure SHC, indexer instances after scale up and standalone in a namespace", func() {

defaultSHReplicas := 3
defaultIndexerReplicas := 3
Expand Down
2 changes: 1 addition & 1 deletion test/scaling_test/scaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ var _ = Describe("Scaling test", func() {
})

Context("Multisite Indexer Cluster (M4 - Multisite indexer Cluster, search head cluster)", func() {
It("scaling_test: Multisite IDXC can be scaled up and data is searchable", func() {
It("scaling_test, integration: Multisite IDXC can be scaled up and data is searchable", func() {

defaultIndexerReplicas := 1
siteCount := 3
Expand Down
135 changes: 135 additions & 0 deletions test/secret/secret_c3_test.go
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() {
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is in that direction.
Hierarchy :
Feature Named Folder -> Individual file for each SVA -> Individual test for those SVA


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
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have APIs:

generateHECToken - Generating a 36 byte HEC token
GenerateSercret - With a parameter of 24 generating 24 byte long secret tokens for everything except hec_token.

Not necessary to use them, but we can maintain uniformity if we re-use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)

})
})
})
Loading