refactor(experiments): Remove manual setting of ConnectedInfraID in chaos experiment tests
- Eliminated the logic for manually setting ConnectedInfraID from ExistingInfraID in multiple chaos experiment tests (container-kill, disk-fill, node-cpu-hog, node-io-stress, node-memory-hog, pod-autoscaler, pod-cpu-hog, pod-memory-hog, pod-network-corruption, pod-network-duplication, pod-network-latency, pod-network-loss, pod-delete). - This change simplifies the infrastructure setup process by relying on the updated logic in the SetupInfrastructure function, enhancing code clarity and maintainability. Signed-off-by: Sky Singh <akashsingh2210670@gmail.com>
This commit is contained in:
parent
8741dd40e0
commit
020d7400aa
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running container-kill experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running disk-fill experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ var _ = Describe("BDD of running node-cpu-hog experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ var _ = Describe("BDD of running node-io-stress experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ var _ = Describe("BDD of running node-memory-hog experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-autoscaler experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-cpu-hog experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-delete experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-memory-hog experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-network-corruption experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-network-duplication experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-network-latency experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -51,10 +51,6 @@ var _ = Describe("BDD of running pod-network-loss experiment", func() {
|
|||
// Setup infrastructure
|
||||
By("[PreChaos]: Setting up infrastructure")
|
||||
err = infrastructure.SetupInfrastructure(&experimentsDetails, sdkClient)
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
Expect(err).To(BeNil(), "Failed to setup infrastructure, due to {%v}", err)
|
||||
|
||||
// Validate that infrastructure ID is properly set
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ func SetupInfrastructure(experimentsDetails *types.ExperimentDetails, sdkClient
|
|||
installInfra, _ := strconv.ParseBool(os.Getenv("INSTALL_INFRA"))
|
||||
if !installInfra {
|
||||
klog.Info("INSTALL_INFRA is set to false, skipping infrastructure setup")
|
||||
// Handle case where we're using existing infrastructure but not installing
|
||||
if experimentsDetails.ConnectedInfraID == "" && experimentsDetails.UseExistingInfra && experimentsDetails.ExistingInfraID != "" {
|
||||
experimentsDetails.ConnectedInfraID = experimentsDetails.ExistingInfraID
|
||||
klog.Infof("Manually set ConnectedInfraID to %s from ExistingInfraID", experimentsDetails.ConnectedInfraID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue