Skip to content

Commit

Permalink
Add some resources required for testing specific test cases (#422)
Browse files Browse the repository at this point in the history
* Add some resources required for testing specific test cases

The ones included in this change allow testing
"lifecycle-affinity-required-pods".
  • Loading branch information
jmontesi authored Apr 18, 2024
1 parent 583109d commit e79a99e
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ install:
./scripts/deploy-test-pods.sh
./scripts/deploy-statefulset-test-pods.sh
./scripts/deploy-pod-disruption-budget.sh
./scripts/deploy-special-resources.sh
./scripts/deploy-test-crds.sh
./scripts/install-olm.sh
./scripts/deploy-community-operator.sh
Expand Down
1 change: 1 addition & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source "$SCRIPT_DIR"/init-env.sh

# Delete tnf, partner and operator and litmus
./"$SCRIPT_DIR"/delete-test-pods.sh
./"$SCRIPT_DIR"/delete-special-resources.sh
./"$SCRIPT_DIR"/delete-hpa.sh
./"$SCRIPT_DIR"/delete-test-crds.sh
./"$SCRIPT_DIR"/delete-debug-ds.sh
Expand Down
13 changes: 13 additions & 0 deletions scripts/delete-special-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Initialization
SCRIPT_DIR=$(dirname "$0")

# shellcheck disable=SC1091 # Not following.
source "$SCRIPT_DIR"/init-env.sh

mkdir -p ./temp

"$SCRIPT_DIR"/mo ./test-target/special-resources.yaml >./temp/rendered-test-special-resources.yaml
oc delete --filename ./temp/rendered-test-special-resources.yaml -n "$TNF_EXAMPLE_CNF_NAMESPACE" --ignore-not-found=true
rm ./temp/rendered-test-special-resources.yaml
13 changes: 13 additions & 0 deletions scripts/deploy-special-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Initialization
SCRIPT_DIR=$(dirname "$0")

# shellcheck disable=SC1091 # Not following.
source "$SCRIPT_DIR"/init-env.sh

mkdir -p ./temp

"$SCRIPT_DIR"/mo ./test-target/special-resources.yaml >./temp/rendered-test-special-resources.yaml
oc apply --filename ./temp/rendered-test-special-resources.yaml --namespace "$TNF_EXAMPLE_CNF_NAMESPACE"
rm ./temp/rendered-test-special-resources.yaml
92 changes: 92 additions & 0 deletions test-target/special-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

apiVersion: apps/v1
kind: Deployment
metadata:
name: special-dp
namespace: {{ TNF_EXAMPLE_CNF_NAMESPACE }}
labels:
test-network-function.com/generic: target
spec:
replicas: 2
selector:
matchLabels:
app: special-dp
template:
metadata:
labels:
test-network-function.com/generic: target
test-network-function.com/container: target
app: special-dp
AffinityRequired: "true"
name: special-dp
spec:
terminationGracePeriodSeconds: 30
automountServiceAccountToken: false
serviceAccountName: test-pod-sa
containers:
- image: quay.io/testnetworkfunction/cnf-test-partner:latest
imagePullPolicy: IfNotPresent
name: test
ports:
- name: "http-probe"
containerPort: 8080
resources:
limits:
memory: 512Mi
cpu: 0.25
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /tmp/message"]
preStop:
exec:
command: ["/bin/sh", "-c", "killall -0 tail"]
livenessProbe:
httpGet:
path: /health
port: 8080
httpHeaders:
- name: health-check
value: liveness
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
httpHeaders:
- name: health-check
value: readiness
initialDelaySeconds: 10
periodSeconds: 5
startupProbe:
httpGet:
path: /health
port: 8080
httpHeaders:
- name: health-check
value: startup
failureThreshold: 10
periodSeconds: 5
command: ["./bin/app"]
terminationMessagePolicy: FallbackToLogsOnError
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/worker
operator: In
values:
- worker
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: special-pdb
namespace: {{ TNF_EXAMPLE_CNF_NAMESPACE }}
spec:
minAvailable: 1
selector:
matchLabels:
app: special-dp

0 comments on commit e79a99e

Please sign in to comment.