Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP Label Selector Experiment Tests #380

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions .github/workflows/gcp-experiment-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
default: "Always"

jobs:
GCP_VM_Instance_Stop:
GCP_VM_Instance_Stop_by_Name_And_Label:
neelanjan00 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
Expand Down Expand Up @@ -70,7 +70,8 @@ jobs:
run: |
gcloud compute instances create litmus-e2e-first-vm-${{ github.run_number }} litmus-e2e-second-vm-${{ github.run_number }} \
--machine-type=f1-micro \
--zone=us-central1-a
--zone=us-east1-b \
--labels=vm=litmus-e2e-vm-${{ github.run_number }}

- name: Litmus Infra Setup
if: always()
Expand All @@ -84,17 +85,29 @@ jobs:
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
VM_INSTANCE_NAMES: "litmus-e2e-first-vm-${{ github.run_number }},litmus-e2e-second-vm-${{ github.run_number }}"
INSTANCE_ZONES: "us-central1-a,us-central1-a"
INSTANCE_ZONES: "us-east1-b,us-east1-b"
EXPERIMENT_IMAGE: "${{ github.event.inputs.experimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-instance-stop

- name: Run GCP VM Instance Stop By Label experiment in serial & parallel mode
if: always()
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
INSTANCE_LABEL: "vm : litmus-e2e-vm-${{ github.run_number }}"
INSTANCE_ZONES: "us-east1-b"
INSTANCE_AFFECTED_PERC: "100"
EXPERIMENT_IMAGE: "${{ github.event.inputs.experimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-instance-stop-by-label

- name: Delete target GCP VM Instances
if: always()
run: |
gcloud compute instances delete litmus-e2e-first-vm-${{ github.run_number }} litmus-e2e-second-vm-${{ github.run_number }} \
--zone=us-central1-a \
--zone=us-east1-b \
--quiet

- name: "[Debug]: check chaos resources"
Expand All @@ -119,11 +132,11 @@ jobs:
if: always()
run: /usr/local/bin/k3s-uninstall.sh

GCP_VM_Disk_Loss:
GCP_VM_Disk_Loss_By_Name_And_Label:
runs-on: ubuntu-latest
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
needs: GCP_VM_Instance_Stop
needs: GCP_VM_Instance_Stop_by_Name_And_Label
avaakash marked this conversation as resolved.
Show resolved Hide resolved
steps:

#Install and configure a k3s cluster
Expand Down Expand Up @@ -175,9 +188,11 @@ jobs:
run: |
gcloud compute instances create litmus-e2e-vm-${{ github.run_number }} \
--machine-type=f1-micro \
--zone=us-central1-a \
--zone=us-east1-b \
--create-disk name=litmus-e2e-first-disk-${{ github.run_number }},size=1GB,device-name=litmus-e2e-first-disk-${{ github.run_number }} \
--create-disk name=litmus-e2e-second-disk-${{ github.run_number }},size=1GB,device-name=litmus-e2e-second-disk-${{ github.run_number }}
gcloud compute disks add-labels litmus-e2e-first-disk-${{ github.run_number }} --labels=disk=litmus-e2e-disk-${{ github.run_number }} --zone=us-east1-b
gcloud compute disks add-labels litmus-e2e-second-disk-${{ github.run_number }} --labels=disk=litmus-e2e-disk-${{ github.run_number }} --zone=us-east1-b

- name: Litmus Infra Setup
if: always()
Expand All @@ -191,18 +206,30 @@ jobs:
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_NAMES: "litmus-e2e-first-disk-${{ github.run_number }},litmus-e2e-second-disk-${{ github.run_number }}"
DISK_ZONES: "us-central1-a,us-central1-a"
DISK_ZONES: "us-east1-b,us-east1-b"
DEVICE_NAMES: "litmus-e2e-first-disk-${{ github.run_number }},litmus-e2e-second-disk-${{ github.run_number }}"
EXPERIMENT_IMAGE: "${{ github.event.inputs.experimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-disk-loss

- name: Run GCP VM Disk Loss By Label experiment in serial & parallel mode
if: always()
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_LABEL: "disk : litmus-e2e-disk-${{ github.run_number }}"
DISK_ZONES: "us-east1-b"
DISK_AFFECTED_PERC: "100"
EXPERIMENT_IMAGE: "${{ github.event.inputs.experimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-disk-loss-by-label

- name: Delete the VM Instance and target Disk Volumes
if: always()
run: |
gcloud compute instances delete litmus-e2e-vm-${{ github.run_number }} \
--zone=us-central1-a \
--zone=us-east1-b \
--delete-disks=all \
--quiet

Expand Down
47 changes: 33 additions & 14 deletions .github/workflows/nightly-gcp-experiment-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ on:
- cron: "30 22 * * *" # Daily 02:30 AM in midnight

jobs:
GCP_VM_Instance_Stop:
GCP_VM_Instance_Stop_by_Name_And_Label:
neelanjan00 marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
env:
env:
neelanjan00 marked this conversation as resolved.
Show resolved Hide resolved
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
steps:

#Install and configure a k3s cluster
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
Expand Down Expand Up @@ -62,7 +60,8 @@ jobs:
run: |
gcloud compute instances create litmus-e2e-first-vm-${{ github.run_number }} litmus-e2e-second-vm-${{ github.run_number }} \
--machine-type=f1-micro \
--zone=us-central1-a
--zone=us-east1-b \
--labels=vm=litmus-e2e-vm-${{ github.run_number }}

- name: Litmus Infra Setup
if: always()
Expand All @@ -73,14 +72,23 @@ jobs:
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
VM_INSTANCE_NAMES: "litmus-e2e-first-vm-${{ github.run_number }},litmus-e2e-second-vm-${{ github.run_number }}"
INSTANCE_ZONES: "us-central1-a,us-central1-a"
INSTANCE_ZONES: "us-east1-b,us-east1-b"
run: make gcp-vm-instance-stop

- name: Run GCP VM Instance Stop By Label experiment in serial & parallel mode
if: always()
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
INSTANCE_LABEL: "vm : litmus-e2e-vm-${{ github.run_number }}"
INSTANCE_ZONES: "us-east1-b"
INSTANCE_AFFECTED_PERC: "100"
run: make gcp-vm-instance-stop-by-label

- name: Delete target GCP VM Instances
if: always()
run: |
gcloud compute instances delete litmus-e2e-first-vm-${{ github.run_number }} litmus-e2e-second-vm-${{ github.run_number }} \
--zone=us-central1-a \
--zone=us-east1-b \
--quiet

- name: "[Debug]: check chaos resources"
Expand All @@ -98,18 +106,18 @@ jobs:
cat logs.txt

- name: Litmus Cleanup
if: ${{ always() }}
if: ${{ always() }}
run: make litmus-cleanup

- name: Deleting K3S cluster
if: always()
run: /usr/local/bin/k3s-uninstall.sh

GCP_VM_Disk_Loss:
GCP_VM_Disk_Loss_By_Name_And_Label:
runs-on: ubuntu-latest
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
needs: GCP_VM_Instance_Stop
needs: GCP_VM_Instance_Stop_by_Name_And_Label
neelanjan00 marked this conversation as resolved.
Show resolved Hide resolved
steps:

#Install and configure a k3s cluster
Expand Down Expand Up @@ -161,9 +169,11 @@ jobs:
run: |
gcloud compute instances create litmus-e2e-vm-${{ github.run_number }} \
--machine-type=f1-micro \
--zone=us-central1-a \
--zone=us-east1-b \
--create-disk name=litmus-e2e-first-disk-${{ github.run_number }},size=1GB,device-name=litmus-e2e-first-disk-${{ github.run_number }} \
--create-disk name=litmus-e2e-second-disk-${{ github.run_number }},size=1GB,device-name=litmus-e2e-second-disk-${{ github.run_number }}
gcloud compute disks add-labels litmus-e2e-first-disk-${{ github.run_number }} --labels=disk=litmus-e2e-disk-${{ github.run_number }} --zone=us-east1-b
gcloud compute disks add-labels litmus-e2e-second-disk-${{ github.run_number }} --labels=disk=litmus-e2e-disk-${{ github.run_number }} --zone=us-east1-b

- name: Litmus Infra Setup
if: always()
Expand All @@ -174,15 +184,24 @@ jobs:
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_NAMES: "litmus-e2e-first-disk-${{ github.run_number }},litmus-e2e-second-disk-${{ github.run_number }}"
DISK_ZONES: "us-central1-a,us-central1-a"
DISK_ZONES: "us-east1-b,us-east1-b"
DEVICE_NAMES: "litmus-e2e-first-disk-${{ github.run_number }},litmus-e2e-second-disk-${{ github.run_number }}"
run: make gcp-vm-disk-loss

- name: Run GCP VM Disk Loss By Label experiment in serial & parallel mode
if: always()
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_LABEL: "disk : litmus-e2e-disk-${{ github.run_number }}"
DISK_ZONES: "us-east1-b"
DISK_AFFECTED_PERC: "100"
run: make gcp-vm-disk-loss-by-label

- name: Delete the VM Instance and target Disk Volumes
if: always()
run: |
gcloud compute instances delete litmus-e2e-vm-${{ github.run_number }} \
--zone=us-central1-a \
--zone=us-east1-b \
--delete-disks=all \
--quiet

Expand All @@ -201,7 +220,7 @@ jobs:
cat logs.txt

- name: Litmus Cleanup
if: ${{ always() }}
if: ${{ always() }}
run: make litmus-cleanup

- name: Deleting K3S cluster
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ gcp-vm-disk-loss:
@echo "------------------------------------------"
@go test platform/gcp/gcp-vm-disk-loss_test.go -v -count=1 -timeout=20m

.PHONY: gcp-vm-instance-stop-by-label
gcp-vm-instance-stop-by-label:

@echo "------------------------------------------"
@echo "Running gcp-vm-instance-stop-by-label experiment"
@echo "------------------------------------------"
@go test platform/gcp/gcp-vm-instance-stop-by-label_test.go -v -count=1 -timeout=20m

.PHONY: gcp-vm-disk-loss-by-label
gcp-vm-disk-loss-by-label:

@echo "------------------------------------------"
@echo "Running gcp-vm-disk-loss-by-label experiment"
@echo "------------------------------------------"
@go test platform/gcp/gcp-vm-disk-loss-by-label_test.go -v -count=1 -timeout=20m

.PHONY: vm-poweroff
vm-poweroff:

Expand Down
4 changes: 4 additions & 0 deletions pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func GetENV(testDetails *types.TestDetails, expName, engineName string) {
testDetails.DiskVolumeNames = Getenv("DISK_VOLUME_NAMES", "")
testDetails.DiskZones = Getenv("DISK_ZONES", "")
testDetails.DeviceNames = Getenv("DEVICE_NAMES", "")
testDetails.InstanceLabel = Getenv("INSTANCE_LABEL", "")
testDetails.InstanceAffectedPercentage = Getenv("INSTANCE_AFFECTED_PERC", "")
testDetails.DiskVolumeLabel = Getenv("DISK_VOLUME_LABEL", "")
testDetails.DiskAffectedPercentage = Getenv("DISK_AFFECTED_PERC", "")
testDetails.VMIds = Getenv("APP_VM_MOIDS", "")
testDetails.Region = Getenv("REGION", "us-west-1")
testDetails.UpdateWebsite = Getenv("UPDATE_WEBSITE", "false")
Expand Down
10 changes: 10 additions & 0 deletions pkg/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ func setEngineVar(chaosEngine *v1alpha1.ChaosEngine, testsDetails *types.TestDet
SetEnv("DISK_VOLUME_NAMES", testsDetails.DiskVolumeNames).
SetEnv("DISK_ZONES", testsDetails.DiskZones).
SetEnv("DEVICE_NAMES", testsDetails.DeviceNames)
case "gcp-vm-instance-stop-by-label":
envDetails.SetEnv("GCP_PROJECT_ID", testsDetails.GCPProjectID).
SetEnv("INSTANCE_LABEL", testsDetails.InstanceLabel).
SetEnv("INSTANCE_ZONES", testsDetails.InstanceZones).
SetEnv("INSTANCE_AFFECTED_PERC", testsDetails.InstanceAffectedPercentage)
case "gcp-vm-disk-loss-by-label":
envDetails.SetEnv("GCP_PROJECT_ID", testsDetails.GCPProjectID).
SetEnv("DISK_VOLUME_LABEL", testsDetails.DiskVolumeLabel).
SetEnv("DISK_ZONES", testsDetails.DiskZones).
SetEnv("DISK_AFFECTED_PERC", testsDetails.DiskAffectedPercentage)
case "vm-poweroff":
envDetails.SetEnv("APP_VM_MOIDS", testsDetails.VMIds)
case "process-kill":
Expand Down
Loading