Skip to content

Commit

Permalink
Chore(engine): Enhance Chaos CI Lib Experiment Execution and add E2E (#…
Browse files Browse the repository at this point in the history
…19)

* Chore(engine): Enhance Chaos CI Lib Experiment Execution and add E2E

Signed-off-by: udit <[email protected]>
  • Loading branch information
uditgaurav authored Jul 14, 2021
1 parent c970021 commit 1b2c0e3
Show file tree
Hide file tree
Showing 37 changed files with 1,201 additions and 455 deletions.
437 changes: 437 additions & 0 deletions .github/workflows/run-e2e-on-pr-commits.yml

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,124 @@ trivy-check:
@echo "------------------------"
@./trivy --exit-code 0 --severity HIGH --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@./trivy --exit-code 0 --severity CRITICAL --no-progress $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG)


.PHONY: install
install:

@echo "--------------------------------------"
@echo "---> Installing LitmusChaos"
@echo "--------------------------------------"
@go test litmus/install-litmus_test.go -v -count=1

.PHONY: uninstall
uninstall:

@echo "--------------------------------------"
@echo "---> Uninstalling LitmusChaos"
@echo "--------------------------------------"
@go test litmus/uninstall-litmus_test.go -v -count=1

.PHONY: container-kill
container-kill:

@echo "--------------------------------------"
@echo "---> Running Container Kill Experiment"
@echo "--------------------------------------"
@go test experiments/container-kill_test.go -v -count=1

.PHONY: disk-fill
disk-fill:

@echo "--------------------------------------"
@echo "---> Running Disk Fill Experiment"
@echo "--------------------------------------"
@go test experiments/disk-fill_test.go -v -count=1

.PHONY: node-cpu-hog
node-cpu-hog:

@echo "--------------------------------------"
@echo "---> Running Node CPU Hog Experiment"
@echo "--------------------------------------"
@go test experiments/node-cpu-hog_test.go -v -count=1

.PHONY: node-io-stress
node-io-stress:

@echo "--------------------------------------"
@echo "---> Running Node IO Stess Experiment"
@echo "--------------------------------------"
@go test experiments/node-io-stress_test.go -v -count=1

.PHONY: node-memory-hog
node-memory-hog:

@echo "--------------------------------------"
@echo "---> Running Node Memory Hog Experiment"
@echo "--------------------------------------"
@go test experiments/node-memory-hog_test.go -v -count=1

.PHONY: pod-autoscaler
pod-autoscaler:

@echo "--------------------------------------"
@echo "---> Running Pod Autoscaler Experiment"
@echo "--------------------------------------"
@go test experiments/pod-autoscaler_test.go -v -count=1

.PHONY: pod-cpu-hog
pod-cpu-hog:

@echo "--------------------------------------"
@echo "---> Running Pod CPU Hog Experiment"
@echo "--------------------------------------"
@go test experiments/pod-cpu-hog_test.go -v -count=1

.PHONY: pod-delete
pod-delete:

@echo "--------------------------------------"
@echo "---> Running Pod Delete Experiment"
@echo "--------------------------------------"
@go test experiments/pod-delete_test.go -v -count=1

.PHONY: pod-memory-hog
pod-memory-hog:

@echo "--------------------------------------"
@echo "---> Running Pod Memory Hog Experiment"
@echo "--------------------------------------"
@go test experiments/pod-memory-hog_test.go -v -count=1

.PHONY: pod-network-corruption
pod-network-corruption:

@echo "--------------------------------------"
@echo "---> Running Pod Network Corruption Experiment"
@echo "--------------------------------------"
@go test experiments/pod-network-corruption_test.go -v -count=1

.PHONY: pod-network-duplication
pod-network-duplication:

@echo "--------------------------------------"
@echo "---> Running Pod Network Duplication Experiment"
@echo "--------------------------------------"
@go test experiments/pod-network-duplication_test.go -v -count=1

.PHONY: pod-network-latency
pod-network-latency:

@echo "--------------------------------------"
@echo "---> Running Pod Network Latency Experiment"
@echo "--------------------------------------"
@go test experiments/pod-network-latency_test.go -v -count=1

.PHONY: pod-network-loss
pod-network-loss:

@echo "--------------------------------------"
@echo "---> Running Pod Network Loss Experiment"
@echo "--------------------------------------"
@go test experiments/pod-network-loss_test.go -v -count=1
6 changes: 4 additions & 2 deletions experiments/container-kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/container-kill/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running container-kill experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running container-kill experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallPodContainerKillEngine(&experimentsDetails)
err = engine.InstallContainerKillEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/disk-fill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/disk-fill/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running disk-fill experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running disk-fill experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallDiskFillEngine(&experimentsDetails)
err = engine.InstallDiskFillEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/node-cpu-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/node-cpu-hog/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running node-cpu-hog experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running node-cpu-hog experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallNodeCPUHogEngine(&experimentsDetails)
err = engine.InstallNodeCPUHogEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/node-io-stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/node-io-stress/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running node-io-stress experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running node-io-stress experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallNodeIOStressEngine(&experimentsDetails)
err = engine.InstallNodeIOStressEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/node-memory-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/node-memory-hog/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running node-memory-hog experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running node-memory-hog experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallNodeMemoryHogEngine(&experimentsDetails)
err = engine.InstallNodeMemoryHogEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/pod-autoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/pod-autoscaler/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running pod-autoscaler experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running pod-autoscaler experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallPodAutoscalerEngine(&experimentsDetails)
err = engine.InstallPodAutoscalerEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/pod-cpu-hog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/pod-cpu-hog/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/log"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running pod-cpu-hog experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running pod-cpu-hog experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallPodCPUHogEngine(&experimentsDetails)
err = engine.InstallPodCPUHogEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
6 changes: 4 additions & 2 deletions experiments/pod-delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/litmuschaos/chaos-ci-lib/pkg/environment"
engine "github.com/litmuschaos/chaos-ci-lib/pkg/generic/pod-delete/lib"
"github.com/litmuschaos/chaos-ci-lib/pkg/types"
"github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -27,6 +28,7 @@ var _ = Describe("BDD of running pod-delete experiment", func() {

experimentsDetails := types.ExperimentDetails{}
clients := environment.ClientSets{}
chaosEngine := v1alpha1.ChaosEngine{}

//Getting kubeConfig and Generate ClientSets
By("[PreChaos]: Getting kubeconfig and generate clientset")
Expand All @@ -45,12 +47,12 @@ var _ = Describe("BDD of running pod-delete experiment", func() {

// Install ChaosEngine for experiment Execution
By("[Prepare]: Prepare and install ChaosEngine")
err = engine.InstallPodDeleteEngine(&experimentsDetails)
err = engine.InstallPodDeleteEngine(&experimentsDetails, &chaosEngine, clients)
Expect(err).To(BeNil(), "fail to install chaosengine, due to {%v}", err)

//Checking runner pod running state
By("[Status]: Runner pod running status check")
_, err = pkg.RunnerPodStatus(&experimentsDetails, experimentsDetails.AppNS, clients)
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
Loading

0 comments on commit 1b2c0e3

Please sign in to comment.