Skip to content

Commit

Permalink
Test/chaos experiments: Tests for handlers and services (#4137)
Browse files Browse the repository at this point in the history
* fix: use local mongo operator

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: gitops mocks added

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: mongo mocks added

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: chaos experiment run mocks added

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: infra mocks added

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: chaos experiment mocks added

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: temporary manifests

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: missing exp-run operator

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: service tests

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: handler tests

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: errors due to package restructure conflicts with upstream

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: infra resolver bug

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: add exp_run mock service

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: gitops mocks

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: typos

Signed-off-by: SohamRatnaparkhi <[email protected]>

* feat: add exp run test files

Signed-off-by: SohamRatnaparkhi <[email protected]>

* chore: remove redundant package

Signed-off-by: SohamRatnaparkhi <[email protected]>

* fix: update exp bugs

Signed-off-by: SohamRatnaparkhi <[email protected]>

---------

Signed-off-by: SohamRatnaparkhi <[email protected]>
Signed-off-by: Soham Ratnaparkhi <[email protected]>
Signed-off-by: Saranya Jena <[email protected]>
Co-authored-by: Namkyu Park <[email protected]>
Co-authored-by: Saranya Jena <[email protected]>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent d8a4896 commit 727ee8a
Show file tree
Hide file tree
Showing 13 changed files with 1,689 additions and 19 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
generateName: nginx-chaos
name: nginx-chaos
namespace: default
spec:
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
# It can be active/stop
engineState: 'active'
chaosServiceAccount: pod-delete-sa
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'

# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'

# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'

## percentage of total pods to target
- name: PODS_AFFECTED_PERC
value: ''
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosSchedule
metadata:
name: schedule-nginx
generateName: schedule-nginx
spec:
schedule:
now: true
engineTemplateSpec:
engineState: 'active'
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
annotationCheck: 'true'
chaosServiceAccount: pod-delete-sa
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'

# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'

# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
kind: CronWorkflow
apiVersion: argoproj.io/v1alpha1
metadata:
name: test-podtato-head-1682669740
namespace: litmus
creationTimestamp: null
labels:
subject: podtato-head_litmus
workflows.argoproj.io/controller-instanceid: 83c20016-f7ec-4c5d-bb84-3a067a7010c2
spec:
workflowSpec:
templates:
- name: argowf-chaos
inputs: {}
outputs: {}
metadata: {}
steps:
- - name: install-application
template: install-application
arguments: {}
- - name: install-chaos-experiments
template: install-chaos-experiments
arguments: {}
- - name: pod-delete
template: pod-delete
arguments: {}
- - name: revert-chaos
template: revert-chaos
arguments: {}
- name: delete-application
template: delete-application
arguments: {}
- name: install-application
inputs: {}
outputs: {}
metadata: {}
container:
name: ""
image: litmuschaos/litmus-app-deployer:latest
args:
- -namespace={{workflow.parameters.adminModeNamespace}}
- -typeName=resilient
- -operation=apply
- -timeout=400
- -app=podtato-head
- -scope=namespace
resources: {}
- name: install-chaos-experiments
inputs: {}
outputs: {}
metadata: {}
container:
name: ""
image: litmuschaos/k8s:latest
command:
- sh
- -c
args:
- kubectl apply -f
https://hub.litmuschaos.io/api/chaos/3.0.0-beta3?file=charts/generic/experiments.yaml
-n {{workflow.parameters.adminModeNamespace}} ; sleep 30
resources: {}
- name: pod-delete
inputs:
artifacts:
- name: pod-delete
path: /tmp/chaosengine.yaml
raw:
data: >
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
namespace: "{{workflow.parameters.adminModeNamespace}}"
labels:
workflow_run_id: "{{workflow.uid}}"
workflow_name: podtato-head-1683012309
generateName: podtato-main-pod-delete-chaos
spec:
appinfo:
appns: "{{workflow.parameters.adminModeNamespace}}"
applabel: name=podtato-main
appkind: deployment
engineState: active
chaosServiceAccount: litmus-admin
jobCleanUpPolicy: retain
components:
runner:
imagePullPolicy: Always
experiments:
- name: pod-delete
spec:
probe:
- name: check-podtato-main-access-url
type: httpProbe
httpProbe/inputs:
url: http://podtato-main.{{workflow.parameters.adminModeNamespace}}.svc.cluster.local:9000
insecureSkipVerify: false
method:
get:
criteria: ==
responseCode: "200"
mode: Continuous
runProperties:
probeTimeout: 1
interval: 1
retry: 1
components:
env:
- name: TOTAL_CHAOS_DURATION
value: "30"
- name: CHAOS_INTERVAL
value: "10"
- name: FORCE
value: "false"
outputs: {}
metadata:
labels:
weight: "10"
container:
name: ""
image: litmuschaos/litmus-checker:latest
args:
- -file=/tmp/chaosengine.yaml
- -saveName=/tmp/engine-name
resources: {}
- name: delete-application
inputs: {}
outputs: {}
metadata: {}
container:
name: ""
image: litmuschaos/litmus-app-deployer:latest
args:
- -namespace={{workflow.parameters.adminModeNamespace}}
- -typeName=resilient
- -operation=delete
- -app=podtato-head
resources: {}
- name: revert-chaos
inputs: {}
outputs: {}
metadata: {}
container:
name: ""
image: litmuschaos/k8s:latest
command:
- sh
- -c
args:
- kubectl delete chaosengine -l workflow_run_id={{workflow.uid}} -n
{{workflow.parameters.adminModeNamespace}}
resources: {}
entrypoint: argowf-chaos
arguments:
parameters:
- name: adminModeNamespace
value: litmus
serviceAccountName: argo-chaos
securityContext:
runAsUser: 1000
runAsNonRoot: true
schedule: 28 16 * * 0-6
concurrencyPolicy: Forbid
startingDeadlineSeconds: 0
timezone: Asia/Seoul
workflowMetadata:
creationTimestamp: null
labels:
cluster_id: 83c20016-f7ec-4c5d-bb84-3a067a7010c2
workflow_id: eb7eb07f-5a60-470a-89e8-7b98ab7e6b11
workflows.argoproj.io/controller-instanceid: 83c20016-f7ec-4c5d-bb84-3a067a7010c2
status:
? active
? lastScheduledTime
? conditions
Loading

0 comments on commit 727ee8a

Please sign in to comment.