Skip to content

Commit 2b4407a

Browse files
committed
fix
Signed-off-by: Udit Gaurav <[email protected]>
1 parent 1b29554 commit 2b4407a

File tree

9 files changed

+30
-25
lines changed

9 files changed

+30
-25
lines changed

components/operator/admin-mode_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func TestAdminModeTest(t *testing.T) {
1919
RunSpecs(t, "BDD test")
2020
}
2121

22-
//BDD Tests for testing admin mode functionality
23-
//Checking for the creation of runner pod for application in same namespace
22+
// BDD Tests for testing admin mode functionality
23+
// Checking for the creation of runner pod for application in same namespace
2424
var _ = Describe("BDD of operator reconcile resiliency check", func() {
2525

2626
// BDD TEST CASE 1
@@ -75,7 +75,7 @@ var _ = Describe("BDD of operator reconcile resiliency check", func() {
7575
//Installing Chaos Engine for container-kill
7676
By("[Install]: Installing chaos engine")
7777
testsDetails.ChaosServiceAccount = "litmus-admin"
78-
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, clients)
78+
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfEmpty, clients)
7979
Expect(err).To(BeNil(), "Failed to install chaosengine due to {%v}", err)
8080

8181
//Checking runner pod running state
@@ -144,7 +144,7 @@ var _ = Describe("BDD of operator reconcile resiliency check", func() {
144144
//Installing Chaos Engine for container-kill
145145
By("[Install]: Installing chaos engine")
146146
testsDetails.ChaosServiceAccount = "litmus-admin"
147-
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, clients)
147+
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfNotEmpty, clients)
148148
Expect(err).To(BeNil(), "Failed to install chaos experiment due to {%v}", err)
149149

150150
//Checking runner pod running state

components/operator/reconcile-resiliency_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func TestReconcileResiliency(t *testing.T) {
2121
RunSpecs(t, "BDD test")
2222
}
2323

24-
//BDD Tests for operator reconcile resiliency
25-
//Checking for the creation of runner pod for application in same namespace
24+
// BDD Tests for operator reconcile resiliency
25+
// Checking for the creation of runner pod for application in same namespace
2626
var _ = Describe("BDD of operator reconcile resiliency check", func() {
2727

2828
// BDD TEST CASE 1
@@ -109,7 +109,7 @@ var _ = Describe("BDD of operator reconcile resiliency check", func() {
109109
//Creating Chaos-Engine for container-kill
110110
By("[Install]: Install Chaos Engine for container-kill")
111111
testsDetails.AppLabel = "run=testapp2"
112-
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, clients)
112+
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfNotEmpty, clients)
113113
Expect(err).To(BeNil(), "Failed to install chaosengine due to {%v}", err)
114114

115115
//Checking the runner pod status
@@ -128,7 +128,7 @@ var _ = Describe("BDD of operator reconcile resiliency check", func() {
128128
By("[Install]: Install Chaos Engine for pod-delete")
129129
testsDetails.AppLabel = "run=testapp1"
130130
testsDetails.AppNS = "default"
131-
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, clients)
131+
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfNotEmpty, clients)
132132
Expect(err).To(BeNil(), "Failed to install chaosengine due to {%v}", err)
133133

134134
// Checking the runner pod status

pkg/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func Kubectl(command ...string) error {
3838
return nil
3939
}
4040

41-
//PrepareChaos install all the Chaos resourses like rbac, experiment and engine
41+
// PrepareChaos install all the Chaos resourses like rbac, experiment and engine
4242
func PrepareChaos(testsDetails *types.TestDetails, chaosExperiment *v1alpha1.ChaosExperiment, chaosEngine *v1alpha1.ChaosEngine, clients environment.ClientSets, annotation bool) error {
4343

4444
testsDetails.AnnotationCheck = strconv.FormatBool(annotation)
@@ -60,7 +60,7 @@ func PrepareChaos(testsDetails *types.TestDetails, chaosExperiment *v1alpha1.Cha
6060

6161
//Installing Chaos Engine
6262
log.Info("[Install]: Installing chaos engine")
63-
err = InstallGoChaosEngine(testsDetails, chaosEngine, testsDetails.ChaosNamespace, clients)
63+
err = InstallGoChaosEngine(testsDetails, chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfNotEmpty, clients)
6464
if err != nil {
6565
return errors.Errorf("Failed to install chaosengine due to {%v}", err)
6666
}

pkg/environment/environment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
types "github.com/litmuschaos/litmus-e2e/pkg/types"
88
)
99

10-
//GetENV fetches all the env variables from the runner pod
10+
// GetENV fetches all the env variables from the runner pod
1111
func GetENV(testDetails *types.TestDetails, expName, engineName string) {
1212
testDetails.ExperimentName = expName
1313
testDetails.EngineName = engineName
@@ -61,8 +61,8 @@ func GetENV(testDetails *types.TestDetails, expName, engineName string) {
6161

6262
// All Links for running chaos testing
6363
testDetails.RbacPath = Getenv("RBAC_PATH", "https://hub.litmuschaos.io/api/chaos/master?file=charts/generic/"+expName+"/rbac.yaml")
64-
testDetails.ExperimentPath = Getenv("EXPERIMENT_PATH", "https://hub.litmuschaos.io/api/chaos/master?file=charts/generic/"+expName+"/experiment.yaml")
65-
testDetails.EnginePath = Getenv("ENGINE_PATH", "https://raw.githubusercontent.com/litmuschaos/chaos-charts/master/charts/generic/"+expName+"/engine.yaml")
64+
testDetails.ExperimentPath = Getenv("EXPERIMENT_PATH", "https://hub.litmuschaos.io/api/chaos/master?file=faults/kubernetes/"+expName+"/fault.yaml")
65+
testDetails.EnginePath = Getenv("ENGINE_PATH", "https://raw.githubusercontent.com/litmuschaos/chaos-charts/master/faults/kubernetes/"+expName+"/engine.yaml")
6666
testDetails.AnsibleRbacPath = Getenv("ANSIBLE_RBAC_PATH", "https://raw.githubusercontent.com/litmuschaos/chaos-charts/master/charts/generic/"+expName+"/ansible/rbac.yaml")
6767
testDetails.AnsibleExperimentPath = Getenv("ANSIBLE_EXPERIMENT_PATH", "https://raw.githubusercontent.com/litmuschaos/chaos-charts/master/charts/generic/"+expName+"/ansible/experiment.yaml")
6868
testDetails.AnsibleEnginePath = Getenv("ANSIBLE_ENGINE_PATH", "https://raw.githubusercontent.com/litmuschaos/chaos-charts/master/charts/generic/"+expName+"/ansible/engine.yaml")

pkg/install.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func UpdateEngine(testsDetails *types.TestDetails, clients environment.ClientSet
105105
engine.Spec.EngineState = v1alpha1.EngineStateActive
106106

107107
// Set all environments
108-
setEngineVar(engine, testsDetails)
108+
setEngineVar(engine, testsDetails, types.SetupAppInfoIfNotEmpty)
109109

110110
_, err = clients.LitmusClient.ChaosEngines(testsDetails.ChaosNamespace).Update(engine)
111111
if err != nil {
@@ -257,7 +257,7 @@ func InstallGoChaosExperiment(testsDetails *types.TestDetails, chaosExperiment *
257257
}
258258

259259
// setEngineVar setting up variables of engine
260-
func setEngineVar(chaosEngine *v1alpha1.ChaosEngine, testsDetails *types.TestDetails) {
260+
func setEngineVar(chaosEngine *v1alpha1.ChaosEngine, testsDetails *types.TestDetails, setAppInfo bool) {
261261

262262
// contains all the envs
263263
envDetails := ENVDetails{
@@ -275,7 +275,7 @@ func setEngineVar(chaosEngine *v1alpha1.ChaosEngine, testsDetails *types.TestDet
275275
chaosEngine.ObjectMeta.Namespace = testsDetails.ChaosNamespace
276276

277277
// If ChaosEngine contain App Info then update it
278-
if chaosEngine.Spec.Appinfo.Appns != "" && chaosEngine.Spec.Appinfo.Applabel != "" {
278+
if (chaosEngine.Spec.Appinfo.Appns != "" && chaosEngine.Spec.Appinfo.Applabel != "") || setAppInfo {
279279
chaosEngine.Spec.Appinfo.Appns = testsDetails.AppNS
280280
chaosEngine.Spec.Appinfo.Applabel = testsDetails.AppLabel
281281
}
@@ -378,7 +378,7 @@ func setEngineVar(chaosEngine *v1alpha1.ChaosEngine, testsDetails *types.TestDet
378378
}
379379

380380
// InstallGoChaosEngine installs the given go based chaos engine
381-
func InstallGoChaosEngine(testsDetails *types.TestDetails, chaosEngine *v1alpha1.ChaosEngine, engineNamespace string, clients environment.ClientSets) error {
381+
func InstallGoChaosEngine(testsDetails *types.TestDetails, chaosEngine *v1alpha1.ChaosEngine, engineNamespace string, setAppInfo bool, clients environment.ClientSets) error {
382382

383383
//Fetch Engine file
384384
res, err := http.Get(testsDetails.EnginePath)
@@ -399,7 +399,7 @@ func InstallGoChaosEngine(testsDetails *types.TestDetails, chaosEngine *v1alpha1
399399
}
400400

401401
// Initialise engine
402-
setEngineVar(chaosEngine, testsDetails)
402+
setEngineVar(chaosEngine, testsDetails, setAppInfo)
403403

404404
// Marshal serializes the values provided into a YAML document.
405405
fileData, err := json.Marshal(chaosEngine)

pkg/types/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package types
22

3+
const (
4+
SetupAppInfoIfEmpty = true
5+
SetupAppInfoIfNotEmpty = false
6+
)
7+
38
// TestDetails is for collecting all the test-related details
49
type TestDetails struct {
510
ExperimentName string

pkg/watch.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func ChaosPodLogs(testsDetails *types.TestDetails, clients environment.ClientSet
2626
return errors.Errorf("Failed to get uid from experiment label,err: %v", err)
2727
}
2828
if err = printHelperPodLogs(testsDetails.ExperimentName, testsDetails.ChaosNamespace, uid, clients); err != nil {
29-
return errors.Errorf("Failed to get the helper pod", err)
29+
return errors.Errorf("failed to get the helper pod, err: %v", err)
3030
}
3131
return nil
3232
}
@@ -68,7 +68,7 @@ func printChaosPodLogs(testsDetails *types.TestDetails, clients environment.Clie
6868
return nil
6969
}
7070

71-
//printHelperPodLogs will print the helper pod logs when the experiment is not passed
71+
// printHelperPodLogs will print the helper pod logs when the experiment is not passed
7272
func printHelperPodLogs(experimentName, namespace, UID string, clients environment.ClientSets) error {
7373

7474
podList, err := clients.KubeClient.CoreV1().Pods(namespace).List(metav1.ListOptions{})
@@ -85,13 +85,13 @@ func printHelperPodLogs(experimentName, namespace, UID string, clients environme
8585
return nil
8686
}
8787

88-
//getPodLogs will print the logs of the given pod
88+
// getPodLogs will print the logs of the given pod
8989
func getPodLogs(podName, namespace string, clients environment.ClientSets) error {
9090

9191
req := clients.KubeClient.CoreV1().Pods(namespace).GetLogs(podName, &v1.PodLogOptions{})
9292
readCloser, err := req.Stream()
9393
if err != nil {
94-
return errors.Errorf("Failed to print the logs of %v pod", podName, err)
94+
return errors.Errorf("failed to print the logs of '%v' pod, err: %v", podName, err)
9595
}
9696
buf := new(bytes.Buffer)
9797
_, err = io.Copy(buf, readCloser)

tests/disk-fill_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestGoDiskFill(t *testing.T) {
1919
RunSpecs(t, "BDD test")
2020
}
2121

22-
//BDD Tests for disk-fill experiment
22+
// BDD Tests for disk-fill experiment
2323
var _ = Describe("BDD of disk-fill experiment", func() {
2424

2525
// BDD TEST CASE 1
@@ -119,7 +119,7 @@ var _ = Describe("BDD of disk-fill experiment", func() {
119119
//Installing Chaos Engine for disk-fill
120120
By("[Install]: Installing chaos engine")
121121
testsDetails.AnnotationCheck = "true"
122-
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, clients)
122+
err = pkg.InstallGoChaosEngine(&testsDetails, &chaosEngine, testsDetails.ChaosNamespace, types.SetupAppInfoIfNotEmpty, clients)
123123
Expect(err).To(BeNil(), "Failed to install chaosengine due to {%v}", err)
124124

125125
//Checking runner pod running state

tests/pod-memory-hog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestGoMemoryHog(t *testing.T) {
2020
RunSpecs(t, "BDD test")
2121
}
2222

23-
//BDD Tests for pod-memory-hog experiment
23+
// BDD Tests for pod-memory-hog experiment
2424
var _ = Describe("BDD of pod-memory-hog experiment", func() {
2525

2626
// BDD TEST CASE 1

0 commit comments

Comments
 (0)