Skip to content

Commit 91d06cd

Browse files
author
Isaak Dorfman
authored
added fsdiff pod to the infra (#20)
This PR adds fsdiff pod to the local test infra. Also added capability of deploying partner pods in custom namespace.
1 parent 350f55e commit 91d06cd

File tree

12 files changed

+1234
-11
lines changed

12 files changed

+1234
-11
lines changed

.github/actions/create-local-test-infra-resources/action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ runs:
3131
run: make install
3232
working-directory: ${{ inputs.working_directory }}
3333
shell: bash
34+
env:
35+
NAMESPACE_TO_GENERATE: ${{ inputs.oc_namespace }}
3436

3537
- name: Set the current context to use the correct TNF namespace
3638
run: oc config set-context $(oc config current-context) --namespace=${{ inputs.oc_namespace }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea
22
.vscode
3+
temp/

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
.PHONY: install \
22
clean
33

4-
install:
5-
oc create -f local-test-infra/namespace.yaml
6-
oc create -f local-test-infra/local-partner-pod.yaml
7-
oc create -f local-test-infra/local-pod-under-test.yaml
8-
4+
install:
5+
bash ./deploy-all.sh
6+
97
clean:
10-
oc delete -f local-test-infra/namespace.yaml
8+
bash ./clean-all.sh

clean-all.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
mkdir -p ./temp
2+
3+
if [[ -z "${NAMESPACE_TO_GENERATE}" ]]; then
4+
export NAMESPACE_TO_GENERATE="tnf"
5+
fi
6+
7+
export res=$(oc get namespace $NAMESPACE_TO_GENERATE 2>&1)
8+
if [[ ${res#Error from server (NotFound):} != ${res} ]]; then
9+
echo "namespace ${NAMESPACE_TO_GENERATE} doesn't exists, no reason to delete"
10+
else
11+
cat ./local-test-infra/namespace.yaml | ./script/mo > ./temp/rendered-namespace.yaml
12+
oc delete -f ./temp/rendered-namespace.yaml
13+
rm ./temp/rendered-namespace.yaml
14+
fi

deploy-all.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
mkdir -p ./temp
2+
3+
if [[ -z "${NAMESPACE_TO_GENERATE}" ]]; then
4+
export NAMESPACE_TO_GENERATE="tnf"
5+
fi
6+
7+
export res=$(oc get namespace $NAMESPACE_TO_GENERATE 2>&1)
8+
if [[ ${res#Error from server (NotFound):} != ${res} ]]; then
9+
cat ./local-test-infra/namespace.yaml | ./script/mo > ./temp/rendered-namespace.yaml
10+
oc apply -f ./temp/rendered-namespace.yaml
11+
rm ./temp/rendered-namespace.yaml
12+
else
13+
echo "namespace ${NAMESPACE_TO_GENERATE} already exists, no reason to recreate"
14+
fi
15+
16+
export res=$(oc get pod -n $NAMESPACE_TO_GENERATE -l test-network-function.com/generic=fs_diff_master 2>&1)
17+
if [[ ${res#No resources found} != ${res} ]]; then
18+
cat ./local-test-infra/fsdiff-pod.yaml | ./script/mo > ./temp/rendered-fsdiff-template.yaml
19+
oc apply -f ./temp/rendered-fsdiff-template.yaml
20+
rm ./temp/rendered-fsdiff-template.yaml
21+
else
22+
echo "fsDiffMasterPod already exists, no reason to recreate"
23+
fi
24+
25+
export res=$(oc get pod -n $NAMESPACE_TO_GENERATE -l test-network-function.com/generic=target 2>&1)
26+
if [[ ${res#No resources found} != ${res} ]]; then
27+
cat ./local-test-infra/local-pod-under-test.yaml | ./script/mo > ./temp/rendered-local-pod-under-test-template.yaml
28+
oc apply -f ./temp/rendered-local-pod-under-test-template.yaml
29+
rm ./temp/rendered-local-pod-under-test-template.yaml
30+
else
31+
echo "partner pod already exists, no reason to recreate"
32+
fi
33+
34+
export res=$(oc get pod -n $NAMESPACE_TO_GENERATE -l test-network-function.com/generic=orchestrator 2>&1)
35+
if [[ ${res#No resources found} != ${res} ]]; then
36+
cat ./local-test-infra/local-partner-pod.yaml | ./script/mo > ./temp/rendered-partner-template.yaml
37+
oc apply -f ./temp/rendered-partner-template.yaml
38+
rm ./temp/rendered-partner-template.yaml
39+
else
40+
echo "partner pod already exists, no reason to recreate"
41+
fi

local-test-infra/fsdiff-pod.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
labels:
5+
app: node-master
6+
test-network-function.com/generic: fs_diff_master
7+
test-network-function.com/container: fs_diff_master
8+
annotations:
9+
test-network-function.com/defaultnetworkinterface: '"eth0"' # optional
10+
name: node-master
11+
namespace: {{ NAMESPACE_TO_GENERATE }}
12+
spec:
13+
# hostPID: true
14+
containers:
15+
- command:
16+
- tail
17+
- -f
18+
- /dev/null
19+
image: quay.io/testnetworkfunction/cnf-test-partner:latest # quay.io/testnetworkfunction/test-network-function
20+
name: master
21+
resources:
22+
limits:
23+
memory: 512Mi
24+
cpu: 0.25
25+
volumeMounts:
26+
- mountPath: /var/lib/containers
27+
name: var-lib-containers
28+
- mountPath: /var/run/containers
29+
name: var-run-containers
30+
- mountPath: /run/runc
31+
name: runc-dir
32+
- mountPath: /var/run/containers/storage/overlay-containers
33+
name: overlay-containers
34+
securityContext:
35+
privileged: true
36+
restartPolicy: Always
37+
volumes:
38+
- name: var-lib-containers
39+
hostPath:
40+
path: /var/lib/containers
41+
type: Directory
42+
- name: var-run-containers
43+
hostPath:
44+
path: /var/run/containers
45+
type: Directory
46+
- name: runc-dir
47+
hostPath:
48+
path: /run/runc
49+
type: Directory
50+
- name: overlay-containers
51+
hostPath:
52+
path: /var/run/containers/storage/overlay-containers
53+
type: Directory

local-test-infra/local-partner-pod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: partner
6-
namespace: tnf
6+
namespace: {{ NAMESPACE_TO_GENERATE }}
77
spec:
88
replicas: 1
99
selector:

local-test-infra/local-pod-under-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apps/v1
33
kind: Deployment
44
metadata:
55
name: test
6-
namespace: tnf
6+
namespace: {{ NAMESPACE_TO_GENERATE }}
77
spec:
88
replicas: 2
99
selector:

local-test-infra/namespace.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
kind: Namespace
33
metadata:
4-
name: tnf
4+
name: {{ NAMESPACE_TO_GENERATE }}
55
labels:
6-
name: tnf
6+
name: {{ NAMESPACE_TO_GENERATE }}

0 commit comments

Comments
 (0)