Skip to content

Commit 813c894

Browse files
modify delete logic
1 parent 91e66b4 commit 813c894

File tree

4 files changed

+50
-33
lines changed

4 files changed

+50
-33
lines changed

test/c3/appframework/appframework_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,10 +2945,15 @@ var _ = Describe("c3appfw test", func() {
29452945
// Verify App Download is completed on Cluster Manager
29462946
testenv.VerifyAppState(ctx, deployment, testcaseEnvInst, deployment.GetName(), cm.Kind, appSourceNameIdxc, appFileList, enterpriseApi.AppPkgPodCopyComplete, enterpriseApi.AppPkgPodCopyPending)
29472947

2948-
//Delete apps from init-apps while app installation is in progress
2949-
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
2950-
podDownloadPath := testenv.AppStagingLocOnPod + appSourceVolumeNameIdxc + testenv.AppInfo[appList[0]]["filename"]
2951-
err = testenv.DeleteFilesOnPod(ctx, deployment, testcaseEnvInst.GetName(), cmPod[0], []string{podDownloadPath})
2948+
//Delete apps from init-apps when app download is complete
2949+
var opPod string
2950+
if testcaseEnvInst.IsOperatorInstalledClusterWide() != "true" {
2951+
opPod = testenv.GetOperatorPodName(testcaseEnvInst.GetName())
2952+
} else {
2953+
opPod = testenv.GetOperatorPodName("splunk-operator")
2954+
}
2955+
podDownloadPath := filepath.Join(splcommon.AppDownloadVolume, "downloadedApps", testenvInstance.GetName(), cm.Kind, deployment.GetName(), enterpriseApi.ScopeCluster, appSourceNameIdxc, testenv.AppInfo[appList[0]]["filename"])
2956+
err = testenv.DeleteFilesOnOperatorPod(ctx, deployment, opPod, []string{podDownloadPath})
29522957
Expect(err).To(Succeed(), "Unable to delete file on pod")
29532958

29542959
// Ensure Cluster Manager goes to Ready phase
@@ -2970,6 +2975,7 @@ var _ = Describe("c3appfw test", func() {
29702975
var idxcPodNames, shcPodNames []string
29712976
idxcPodNames = testenv.GeneratePodNameSlice(testenv.IndexerPod, deployment.GetName(), indexerReplicas, false, 1)
29722977
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), indexerReplicas, false, 1)
2978+
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
29732979
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
29742980
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appList, CrAppFileList: appFileList, CrReplicas: indexerReplicas, CrClusterPods: idxcPodNames}
29752981
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appList, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}

test/m4/appframework/appframework_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,10 +2509,15 @@ var _ = Describe("m4appfw test", func() {
25092509
// Verify App Download is completed on Cluster Manager
25102510
testenv.VerifyAppState(ctx, deployment, testcaseEnvInst, deployment.GetName(), cm.Kind, appSourceNameIdxc, appFileList, enterpriseApi.AppPkgPodCopyComplete, enterpriseApi.AppPkgPodCopyPending)
25112511

2512-
//Delete apps from init-apps while app installation is in progress
2513-
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
2514-
podDownloadPath := testenv.AppStagingLocOnPod + appSourceVolumeNameIdxc + testenv.AppInfo[appList[0]]["filename"]
2515-
err = testenv.DeleteFilesOnPod(ctx, deployment, testcaseEnvInst.GetName(), cmPod[0], []string{podDownloadPath})
2512+
//Delete apps from init-apps when app download is complete
2513+
var opPod string
2514+
if testcaseEnvInst.IsOperatorInstalledClusterWide() != "true" {
2515+
opPod = testenv.GetOperatorPodName(testcaseEnvInst.GetName())
2516+
} else {
2517+
opPod = testenv.GetOperatorPodName("splunk-operator")
2518+
}
2519+
podDownloadPath := filepath.Join(splcommon.AppDownloadVolume, "downloadedApps", testenvInstance.GetName(), cm.Kind, deployment.GetName(), enterpriseApi.ScopeCluster, appSourceNameIdxc, testenv.AppInfo[appList[0]]["filename"])
2520+
err = testenv.DeleteFilesOnOperatorPod(ctx, deployment, opPod, []string{podDownloadPath})
25162521
Expect(err).To(Succeed(), "Unable to delete file on pod")
25172522

25182523
// Ensure that the Cluster Manager goes to Ready phase
@@ -2537,6 +2542,7 @@ var _ = Describe("m4appfw test", func() {
25372542
var idxcPodNames, shcPodNames []string
25382543
idxcPodNames = testenv.GeneratePodNameSlice(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, true, siteCount)
25392544
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)
2545+
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
25402546
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
25412547
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appList, CrAppFileList: appFileList, CrReplicas: indexersPerSite, CrMultisite: true, CrClusterPods: idxcPodNames}
25422548
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appList, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}

test/s1/appframework/appframework_test.go

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var _ = Describe("s1appfw test", func() {
6868
}
6969
})
7070

71-
XContext("Standalone deployment (S1) with App Framework", func() {
71+
Context("Standalone deployment (S1) with App Framework", func() {
7272
It("smoke, s1, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, install apps then upgrade them", func() {
7373

7474
/* Test Steps
@@ -230,7 +230,7 @@ var _ = Describe("s1appfw test", func() {
230230
})
231231
})
232232

233-
XContext("Standalone deployment (S1) with App Framework", func() {
233+
Context("Standalone deployment (S1) with App Framework", func() {
234234
It("smoke, s1, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, install apps then downgrade them", func() {
235235

236236
/* Test Steps
@@ -393,7 +393,7 @@ var _ = Describe("s1appfw test", func() {
393393
})
394394
})
395395

396-
XContext("Standalone deployment (S1) with App Framework", func() {
396+
Context("Standalone deployment (S1) with App Framework", func() {
397397
It("s1, smoke, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, install apps, scale up, install apps on new pod, scale down", func() {
398398

399399
/* Test Steps
@@ -570,7 +570,7 @@ var _ = Describe("s1appfw test", func() {
570570
})
571571
})
572572

573-
XContext("Standalone deployment (S1) with App Framework", func() {
573+
Context("Standalone deployment (S1) with App Framework", func() {
574574
It("s1, integration, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, install apps, scale up, upgrade apps", func() {
575575

576576
/* Test Steps
@@ -778,7 +778,7 @@ var _ = Describe("s1appfw test", func() {
778778
})
779779
})
780780

781-
XContext("Standalone deployment (S1) with App Framework", func() {
781+
Context("Standalone deployment (S1) with App Framework", func() {
782782
It("integration, s1, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled and install around 350MB of apps at once", func() {
783783

784784
/* Test Steps
@@ -847,7 +847,7 @@ var _ = Describe("s1appfw test", func() {
847847
})
848848
})
849849

850-
XContext("Standalone deployment (S1) with App Framework", func() {
850+
Context("Standalone deployment (S1) with App Framework", func() {
851851
It("s1, smoke, appframeworks1, appframework: can deploy a standalone instance with App Framework enabled for manual poll", func() {
852852

853853
/* Test Steps
@@ -1025,7 +1025,7 @@ var _ = Describe("s1appfw test", func() {
10251025
})
10261026
})
10271027

1028-
XContext("Standalone deployment (S1) with App Framework", func() {
1028+
Context("Standalone deployment (S1) with App Framework", func() {
10291029
It("integration, s1, appframeworks1, appframework: can deploy Several standalone CRs in the same namespace with App Framework enabled", func() {
10301030

10311031
/* Test Steps
@@ -1126,7 +1126,7 @@ var _ = Describe("s1appfw test", func() {
11261126
})
11271127
})
11281128

1129-
XContext("Standalone deployment (S1) with App Framework", func() {
1129+
Context("Standalone deployment (S1) with App Framework", func() {
11301130
It("integration, s1, appframeworks1, appframework: can add new apps to app source while install is in progress and have all apps installed", func() {
11311131

11321132
/* Test Steps
@@ -1238,7 +1238,7 @@ var _ = Describe("s1appfw test", func() {
12381238
})
12391239
})
12401240

1241-
XContext("Standalone deployment (S1) with App Framework", func() {
1241+
Context("Standalone deployment (S1) with App Framework", func() {
12421242
It("integration, s1, appframeworks1, appframework: Deploy a Standalone instance with App Framework enabled and reset operator pod while app install is in progress", func() {
12431243

12441244
/* Test Steps
@@ -1306,7 +1306,7 @@ var _ = Describe("s1appfw test", func() {
13061306
})
13071307
})
13081308

1309-
XContext("Standalone deployment (S1) with App Framework", func() {
1309+
Context("Standalone deployment (S1) with App Framework", func() {
13101310
It("integration, s1, appframeworks1, appframework: Deploy a Standalone instance with App Framework enabled and reset operator pod while app download is in progress", func() {
13111311

13121312
/* Test Steps
@@ -1374,7 +1374,7 @@ var _ = Describe("s1appfw test", func() {
13741374
})
13751375
})
13761376

1377-
XContext("Standalone deployment (S1) with App Framework", func() {
1377+
Context("Standalone deployment (S1) with App Framework", func() {
13781378
It("integration, s1, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, install an app, then disable it by using a disabled version of the app and then remove it from app source", func() {
13791379

13801380
/* Test Steps
@@ -1478,7 +1478,7 @@ var _ = Describe("s1appfw test", func() {
14781478
})
14791479
})
14801480

1481-
XContext("Standalone deployment (S1) with App Framework", func() {
1481+
Context("Standalone deployment (S1) with App Framework", func() {
14821482
It("integration, s1, appframeworks1, appframework: can deploy a Standalone instance with App Framework enabled, attempt to update using incorrect S3 credentials", func() {
14831483

14841484
/* Test Steps
@@ -1614,7 +1614,7 @@ var _ = Describe("s1appfw test", func() {
16141614
})
16151615
})
16161616

1617-
XContext("Standalone deployment (S1) with App Framework", func() {
1617+
Context("Standalone deployment (S1) with App Framework", func() {
16181618
It("integration, s1, appframeworks1, appframework: Deploy a Standalone instance with App Framework enabled and update apps after app download is completed", func() {
16191619

16201620
/* Test Steps
@@ -1712,7 +1712,7 @@ var _ = Describe("s1appfw test", func() {
17121712
})
17131713
})
17141714

1715-
XContext("Standalone deployment (S1) with App Framework", func() {
1715+
Context("Standalone deployment (S1) with App Framework", func() {
17161716
It("integration, s1, appframeworks1, appframework: can deploy a Standalone instance and install a bigger volume of apps than the operator PV disk space", func() {
17171717

17181718
/* Test Steps
@@ -1832,9 +1832,15 @@ var _ = Describe("s1appfw test", func() {
18321832
testenv.VerifyAppState(ctx, deployment, testcaseEnvInst, deployment.GetName(), standalone.Kind, appSourceName, appFileList, enterpriseApi.AppPkgPodCopyComplete, enterpriseApi.AppPkgPodCopyPending)
18331833

18341834
//Delete apps from init-apps when app download is complete
1835-
standalonePod := []string{fmt.Sprintf(testenv.StandalonePod, deployment.GetName(), 0)}
1836-
podDownloadPath := testenv.AppStagingLocOnPod + appSourceName + "/" + testenv.AppInfo[appList[0]]["filename"]
1837-
err = testenv.DeleteFilesOnPod(ctx, deployment, testcaseEnvInst.GetName(), standalonePod[0], []string{podDownloadPath})
1835+
var opPod string
1836+
if testcaseEnvInst.IsOperatorInstalledClusterWide() != "true" {
1837+
opPod = testenv.GetOperatorPodName(testcaseEnvInst.GetName())
1838+
1839+
} else {
1840+
opPod = testenv.GetOperatorPodName("splunk-operator")
1841+
}
1842+
podDownloadPath := filepath.Join(splcommon.AppDownloadVolume, "downloadedApps", testenvInstance.GetName(), standalone.Kind, deployment.GetName(), enterpriseApi.ScopeLocal, appSourceName, testenv.AppInfo[appList[0]]["filename"])
1843+
err = testenv.DeleteFilesOnOperatorPod(ctx, deployment, opPod, []string{podDownloadPath})
18381844
Expect(err).To(Succeed(), "Unable to delete file on pod")
18391845

18401846
// Wait for Standalone to be in READY status
@@ -1844,6 +1850,7 @@ var _ = Describe("s1appfw test", func() {
18441850
splunkPodAge := testenv.GetPodsStartTime(testcaseEnvInst.GetName())
18451851

18461852
// ############ VERIFICATION ###########
1853+
standalonePod := []string{fmt.Sprintf(testenv.StandalonePod, deployment.GetName(), 0)}
18471854
standaloneAppSourceInfo := testenv.AppSourceInfo{CrKind: standalone.Kind, CrName: standalone.Name, CrAppSourceName: appSourceName, CrPod: standalonePod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeLocal, CrAppList: appList, CrAppFileList: appFileList}
18481855
allAppSourceInfo := []testenv.AppSourceInfo{standaloneAppSourceInfo}
18491856
testenv.AppFrameWorkVerifications(ctx, deployment, testcaseEnvInst, allAppSourceInfo, splunkPodAge, "")

test/testenv/util.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,13 @@ func DeleteOperatorPod(testcaseEnvInst *TestCaseEnv) error {
891891
return nil
892892
}
893893

894-
// DeleteFilesOnPod Delete files on Pod in the namespace
895-
func DeleteFilesOnPod(ctx context.Context, deployment *Deployment, ns string, podName string, filenames []string) error {
896-
for _, file := range filenames {
897-
output, _ := exec.Command("kubectl", "exec", "-n", ns, podName, "--", "ls", file).Output()
898-
logf.Log.Info("files present in location", "location", output)
899-
output, err := exec.Command("kubectl", "exec", "-n", ns, podName, "--", "rm", "-f", file).Output()
894+
// DeleteFilesOnOperatorPod Delete files on Operator Pod
895+
func DeleteFilesOnOperatorPod(ctx context.Context, deployment *Deployment, podName string, filenames []string) error {
896+
for _, filepath := range filenames {
897+
cmd := fmt.Sprintf("rm -f %s", filepath)
898+
_, err := ExecuteCommandOnOperatorPod(ctx, deployment, podName, cmd)
900899
if err != nil {
901-
command := fmt.Sprintf("kubectl exec -n %s %s -- rm -f %s", ns, podName, file)
902-
logf.Log.Error(err, "Failed to delete file on pod ", "PodName", podName, "Namespace", ns, "command", command, "output", output)
900+
logf.Log.Error(err, "Failed to delete file on pod ", "PodName", podName, "location", filepath, "command", cmd)
903901
return err
904902
}
905903
}

0 commit comments

Comments
 (0)