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
13 changes: 7 additions & 6 deletions test/c3/appframework/appframework_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ var _ = BeforeSuite(func() {
testenvInstance, err = testenv.NewDefaultTestEnv(testSuiteName)
Expect(err).ToNot(HaveOccurred())

// List V1 apps on S3
appListV1 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV1)
testenvInstance.Log.Info("V1 Apps found on S3", "App List", appListV1)
// Parse Applist1 to create Valid Apps1
appListV1 = testenv.BasicApps

// Download V1 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV1, downloadDirV1, appListV1)
Expect(err).To(Succeed(), "Unable to download V1 app files")

// List V2 apps on S3
appListV2 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV2)
testenvInstance.Log.Info("V2 Apps found on S3", "App List", appListV2)
// Parse ValidAppsV1 to create Valid Apps2
appListV2 = make([]string, 0, len(appListV1))
for _, app := range appListV1 {
appListV2 = append(appListV2, testenv.AppInfo[app]["V2filename"])
}

// Download V2 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV2, downloadDirV2, appListV2)
Expand Down
29 changes: 29 additions & 0 deletions test/c3/appframework/appframework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package c3appfw

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -106,6 +107,34 @@ var _ = Describe("c3appfw test", func() {
initContDownloadLocation := "/init-apps/" + appSourceName
podNames := []string{fmt.Sprintf(testenv.ClusterMasterPod, deployment.GetName()), fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), podNames, appListV1, initContDownloadLocation)

//Verify Apps are copied to location
allPodNames := testenv.DumpGetPods(testenvInstance.GetName())
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, true)

//Verify Apps are installed
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, "enabled", false, true)

//Delete apps on S3 for new Apps
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil

//Upload new Versioned Apps to S3
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDir, appListV2, downloadDirV2)
Expect(err).To(Succeed(), "Unable to upload apps to S3 test directory")
uploadedApps = append(uploadedApps, uploadedFiles...)

// Wait for the poll period for the apps to be downloaded
time.Sleep(2 * time.Minute)

// Verify Apps are downloaded by init-container
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), podNames, appListV2, initContDownloadLocation)

//Verify Apps are copied to location
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV2, true, true)

//Verify Apps are updated
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, "enabled", true, true)
})
})
})
13 changes: 7 additions & 6 deletions test/m4/appframework/appframework_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ var _ = BeforeSuite(func() {
testenvInstance, err = testenv.NewDefaultTestEnv(testSuiteName)
Expect(err).ToNot(HaveOccurred())

// List V1 apps on S3
appListV1 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV1)
testenvInstance.Log.Info("V1 Apps found on S3", "App List", appListV1)
// create Valid Apps1
appListV1 = testenv.BasicApps

// Download V1 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV1, downloadDirV1, appListV1)
Expect(err).To(Succeed(), "Unable to download V1 app files")

// List V2 apps on S3
appListV2 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV2)
testenvInstance.Log.Info("V2 Apps found on S3", "App List", appListV2)
// Parse ValidAppsV1 to create Valid Apps2
appListV2 = make([]string, 0, len(appListV1))
for _, app := range appListV1 {
appListV2 = append(appListV2, testenv.AppInfo[app]["V2filename"])
}

// Download V2 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV2, downloadDirV2, appListV2)
Expand Down
29 changes: 29 additions & 0 deletions test/m4/appframework/appframework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package m4appfw

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -107,6 +108,34 @@ var _ = Describe("m4appfw test", func() {
initContDownloadLocation := "/init-apps/" + appSourceName
podNames := []string{fmt.Sprintf(testenv.ClusterMasterPod, deployment.GetName()), fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), podNames, appListV1, initContDownloadLocation)

//Verify Apps are copied to location
allPodNames := testenv.DumpGetPods(testenvInstance.GetName())
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, true)

//Verify Apps are installed cluster-wide
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, "enabled", false, true)

//Delete apps on S3 for new Apps
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil

//Upload new Versioned Apps to S3
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDir, appListV2, downloadDirV2)
Expect(err).To(Succeed(), "Unable to upload apps to S3 test directory")
uploadedApps = append(uploadedApps, uploadedFiles...)

// Wait for the poll period for the apps to be downloaded
time.Sleep(2 * time.Minute)

// Verify Apps are downloaded by init-container
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), podNames, appListV2, initContDownloadLocation)

//Verify Apps are copied to location
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV2, true, true)

//Verify Apps are installed cluster-wide
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), allPodNames, appListV1, true, "enabled", true, true)
})
})
})
13 changes: 7 additions & 6 deletions test/s1/appframework/appframework_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ var _ = BeforeSuite(func() {
testenvInstance, err = testenv.NewDefaultTestEnv(testSuiteName)
Expect(err).ToNot(HaveOccurred())

// List V1 apps on S3
appListV1 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV1)
testenvInstance.Log.Info("V1 Apps found on S3", "App List", appListV1)
// Create Valid apps
appListV1 = testenv.BasicApps

// Download V1 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV1, downloadDirV1, appListV1)
Expect(err).To(Succeed(), "Unable to download V1 app files")

// List V2 apps on S3
appListV2 = testenv.GetFilesInPathOnS3(testDataS3Bucket, s3AppDirV2)
testenvInstance.Log.Info("V2 Apps found on S3", "App List", appListV2)
// Parse ValidAppsV1 to create Valid Apps2
appListV2 = make([]string, 0, len(appListV1))
for _, app := range appListV1 {
appListV2 = append(appListV2, testenv.AppInfo[app]["V2filename"])
}

// Download V2 Apps from S3
err = testenv.DownloadFilesFromS3(testDataS3Bucket, s3AppDirV2, downloadDirV2, appListV2)
Expand Down
29 changes: 29 additions & 0 deletions test/s1/appframework/appframework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package s1appfw

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -108,6 +109,34 @@ var _ = Describe("s1appfw test", func() {
initContDownloadLocation := "/init-apps/" + appSourceName
podName := fmt.Sprintf(testenv.StandalonePod, deployment.GetName(), 0)
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV1, initContDownloadLocation)

//Verify Apps are copied to location
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV1, true, true)

//Verify Apps are installed
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV1, true, "enabled", false, false)

//Delete apps on S3 for new Apps
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil

//Upload new Versioned Apps to S3
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDir, appListV2, downloadDirV2)
Expect(err).To(Succeed(), "Unable to upload apps to S3 test directory")
uploadedApps = append(uploadedApps, uploadedFiles...)

// Wait for the poll period for the apps to be downloaded
time.Sleep(2 * time.Minute)

// Verify Apps are downloaded by init-container
testenv.VerifyAppsDownloadedByInitContainer(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV2, initContDownloadLocation)

//Verify Apps are copied to location
testenv.VerifyAppsCopied(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV2, true, true)

//Verify Apps are installed
testenv.VerifyAppInstalled(deployment, testenvInstance, testenvInstance.GetName(), []string{podName}, appListV2, true, "enabled", true, false)

})
})
})
48 changes: 43 additions & 5 deletions test/testenv/appframework_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

//AppInfo Installation info on Apps
var AppInfo = map[string]map[string]string{
"splunk-common-information-model-cim_4181.tgz": {"App-name": "Splunk_SA_CIM", "V1": "4.18.1", "V2": "4.19.0", "V2filename": "splunk-common-information-model-cim_4190.tgz"},
"Add-on-for-ldap_400.tgz": {"App-name": "TA-LDAP", "V1": "4.0.0", "V2": "4.0.0", "V2filename": "Add-on-for-ldap_400.tgz"},
"splunk-es-content-update_3200.tgz": {"App-name": "DA-ESS-ContentUpdate", "V1": "3.20.0", "V2": "3.21.0", "V2filename": "splunk-es-content-update_3210.tgz"},
"palo-alto-networks-add-on-for-splunk_660.tgz": {"App-name": "Splunk_TA_paloalto", "V1": "6.6.0", "V2": "7.0.0", "V2filename": "palo-alto-networks-add-on-for-splunk_700.tgz"},
"microsoft-azure-add-on-for-splunk_300.tgz": {"App-name": "TA-MS-AAD", "V1": "3.0.0", "V2": "3.1.1", "V2filename": "microsoft-azure-add-on-for-splunk_311.tgz"},
"splunk-add-on-for-unix-and-linux_830.tgz": {"App-name": "Splunk_TA_nix", "V1": "8.3.0", "V2": "8.3.0", "V2filename": "splunk-add-on-for-unix-and-linux_830.tgz"},
"splunk-app-for-microsoft-exchange_401.tgz": {"App-name": "splunk_app_microsoft_exchange", "V1": "4.0.1", "V2": "4.0.2", "V2filename": "splunk-app-for-microsoft-exchange_402.tgz"},
"Splunk-app-for-aws_601.tgz": {"App-name": "splunk_app_aws", "V1": "6.0.1", "V2": "6.0.2", "V2filename": "Splunk-app-for-aws_602.tgz"},
"splunk-machine-learning-toolkit_520.tgz": {"App-name": "Splunk_ML_Toolkit", "V1": "5.2.0", "V2": "5.2.1", "V2filename": "splunk-machine-learning-toolkit_521.tgz"},
"splunk-add-on-for-microsoft-cloud-services_412.tgz": {"App-name": "Splunk_TA_microsoft-cloudservices", "V1": "4.1.2", "V2": "4.1.3", "V2filename": "splunk-add-on-for-microsoft-cloud-services_413.tgz"},
"Splunk-app-for-stream_720.tgz": {"App-name": "splunk_app_stream", "V1": "6.0.1", "V2": "6.0.2", "V2filename": "Splunk-app-for-stream_720.tgz"},
"Splunk-db-connect_350.tgz": {"App-name": "splunk_app_db_connect", "V1": "3.5.0", "V2": "3.5.1", "V2filename": "Splunk-db-connect_351.tgz"},
"Splunk-security-essentials_332.tgz": {"App-name": "Splunk_Security_Essentials", "V1": "3.3.2", "V2": "3.3.3", "V2filename": "Splunk-security-essentials_333.tgz"},
//Need to explore these apps for their app Name and installation steps
"splunk-app-for-vmware_401.tgz": {"App-name": "", "V1": "4.0.1", "V2": "4.0.2", "V2filename": "splunk-app-for-vmware_402.tgz"},
"splunk-it-service-intelligence_472.spl": {"App-name": "", "V1": "4.7.2", "V2": "4.9.0", "V2filename": "splunk-it-service-intelligence_490.spl"},
"splunk-enterprise-security_640.spl": {"App-name": "", "V1": "6.4.0", "V2": "6.4.1", "V2filename": "splunk-enterprise-security_641.spl"},
}

//BasicApps Apps that require no restart to be installed
var BasicApps = []string{"splunk-common-information-model-cim_4181.tgz", "splunk-es-content-update_3200.tgz", "palo-alto-networks-add-on-for-splunk_660.tgz", "microsoft-azure-add-on-for-splunk_300.tgz"}

//RestartNeededApps Apps that require restart to be installed
var RestartNeededApps = []string{"splunk-add-on-for-unix-and-linux_830.tgz", "splunk-app-for-microsoft-exchange_401.tgz", "Splunk-app-for-aws_601.tgz", "splunk-machine-learning-toolkit_520.tgz", "splunk-add-on-for-microsoft-cloud-services_412.tgz", "Splunk-app-for-stream_720.tgz", "Splunk-db-connect_350.tgz", "Splunk-security-essentials_332.tgz"}

//AdditionalStepsApps Apps that require additional steps to be installed
var AdditionalStepsApps = []string{"splunk-app-for-vmware_401.tgz", "splunk-it-service-intelligence_472.spl", "splunk-enterprise-security_640.spl"}

// GenerateAppSourceSpec return AppSourceSpec struct with given values
func GenerateAppSourceSpec(appSourceName string, appSourceLocation string, appSourceDefaultSpec enterprisev1.AppSourceDefaultSpec) enterprisev1.AppSourceSpec {
return enterprisev1.AppSourceSpec{
Expand All @@ -20,7 +50,7 @@ func GenerateAppSourceSpec(appSourceName string, appSourceLocation string, appSo
// GetPodAppStatus Get the app install status and version number
func GetPodAppStatus(deployment *Deployment, podName string, ns string, appname string) (string, string, error) {
output, _ := GetPodAppInstallStatus(deployment, podName, ns, appname)
status := strings.Fields(output)[1]
status := strings.Fields(output)[2]
version, err := GetPodInstalledAppVersion(deployment, podName, ns, appname)
return status, version, err

Expand All @@ -30,23 +60,31 @@ func GetPodAppStatus(deployment *Deployment, podName string, ns string, appname
func GetPodInstalledAppVersion(deployment *Deployment, podName string, ns string, appname string) (string, error) {
path := "etc/apps"
if strings.Contains(podName, "-indexer-") {
path = "etc/slave-apps/_cluster/default"
path = "etc/slave-apps/"
}
filePath := fmt.Sprintf("/opt/splunk/%s/%s/default/app.conf", path, appname)
logf.Log.Info("Check Version for app", "AppName", appname, "config", filePath)

confline, err := GetConfLineFromPod(podName, filePath, ns, "Version", "", false)
confline, err := GetConfLineFromPod(podName, filePath, ns, "version", "launcher", true)
if err != nil {
logf.Log.Error(err, "Failed to get Version from pod", "Pod Name", podName)
return "", err
}
version := strings.TrimSpace(strings.Split(confline, " ")[2])
version := strings.TrimSpace(strings.Split(confline, "=")[1])
return version, err

}

// GetPodAppInstallStatus Get the app install status
func GetPodAppInstallStatus(deployment *Deployment, podName string, ns string, appname string) (string, error) {
stdin := fmt.Sprintf("/opt/splunk/bin/splunk display app '%s'", appname)
//Get password to via secret object
namespaceScopedSecretName := fmt.Sprintf(NamespaceScopedSecretObjectName, ns)
secretStruct, _ := GetSecretStruct(deployment, ns, namespaceScopedSecretName)
logf.Log.Info("Data in secret object", "data", secretStruct.Data)
pwd := DecryptSplunkEncodedSecret(deployment, podName, ns, string(secretStruct.Data["password"]))

//Use password to access info
stdin := fmt.Sprintf("/opt/splunk/bin/splunk display app '%s' -auth admin:%s", appname, pwd)
command := []string{"/bin/sh"}
stdout, stderr, err := deployment.PodExecCommand(podName, command, stdin, false)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/testenv/s3utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func DownloadFileFromS3(dataBucket string, filename string, s3FilePath string, d
defer file.Close()

sess, err := S3Session()
if err == nil {
if err != nil {
return "", err
}

Expand Down
Loading