Skip to content

Commit

Permalink
check for resources in chaos namespace, with APP NS as a backup (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: Aarushi Kansal <[email protected]>
  • Loading branch information
aarushik93 authored Jul 28, 2022
1 parent 2895a20 commit 787c7aa
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 17 deletions.
5 changes: 4 additions & 1 deletion experiments/container-kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running container-kill experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/disk-fill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running disk-fill experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/node-cpu-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running node-cpu-hog experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/node-io-stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running node-io-stress experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/node-memory-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running node-memory-hog experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-autoscaler experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-cpu-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-cpu-hog experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-delete experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-memory-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-memory-hog experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-network-corruption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-network-corruption experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-network-duplication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-network-duplication experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-network-latency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-network-latency experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
5 changes: 4 additions & 1 deletion experiments/pod-network-loss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ var _ = Describe("BDD of running pod-network-loss experiment", func() {

//Checking runner pod running state
By("[Status]: Runner pod running status check")
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
err = pkg.RunnerPodStatus(&experimentsDetails, chaosEngine.Namespace, clients)
if err != nil && chaosEngine.Namespace != experimentsDetails.AppNS {
err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
}
Expect(err).To(BeNil(), "Runner pod status check failed, due to {%v}", err)

//Chaos pod running status check
Expand Down
15 changes: 11 additions & 4 deletions pkg/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,25 @@ func ChaosPodLogs(experimentsDetails *types.ExperimentDetails, clients environme
// printChaosPodLogs will wait for the chaosPod to get completed and then prints the logs of it.
func printChaosPodLogs(experimentsDetails *types.ExperimentDetails, clients environment.ClientSets) error {

chaosEngine, err := clients.LitmusClient.ChaosEngines(experimentsDetails.AppNS).Get(experimentsDetails.EngineName, metav1.GetOptions{})
chaosEngine, err := clients.LitmusClient.ChaosEngines(experimentsDetails.ChaosNamespace).Get(experimentsDetails.EngineName, metav1.GetOptions{})
if err != nil {
return errors.Errorf("fail to get the chaosengine %v err: %v", experimentsDetails.EngineName, err)
chaosEngine, err = clients.LitmusClient.ChaosEngines(experimentsDetails.AppNS).Get(experimentsDetails.EngineName, metav1.GetOptions{})
if err != nil {
return errors.Errorf("fail to get the chaosengine %v err: %v", experimentsDetails.EngineName, err)
}
}

if len(chaosEngine.Status.Experiments) == 0 {
return errors.Errorf("fail to get the chaos pod for the test")
}
for count := 0; count < 3000; count++ {

chaosPod, err := clients.KubeClient.CoreV1().Pods(experimentsDetails.AppNS).Get(chaosEngine.Status.Experiments[0].ExpPod, metav1.GetOptions{})
chaosPod, err := clients.KubeClient.CoreV1().Pods(experimentsDetails.ChaosNamespace).Get(chaosEngine.Status.Experiments[0].ExpPod, metav1.GetOptions{})
if err != nil {
return errors.Errorf("fail to get the chaos pod err: %v", err)
chaosPod, err = clients.KubeClient.CoreV1().Pods(experimentsDetails.AppNS).Get(chaosEngine.Status.Experiments[0].ExpPod, metav1.GetOptions{})
if err != nil {
return errors.Errorf("fail to get the chaos pod err: %v", err)
}
}
if chaosPod.Status.Phase != "Succeeded" {
if chaosPod.Status.Phase != "Running" && chaosPod.Status.Phase != "Pending" {
Expand Down

0 comments on commit 787c7aa

Please sign in to comment.