3 To accommodate the git repo access issue, the cgts-client and distributed client are
4 cloned into temp before docker building
9 git clone --branch r/stx.7.0 https://opendev.org/starlingx/config.git
10 git clone --branch master https://opendev.org/starlingx/distcloud-client.git
11 (cd distcloud-client && git reset --hard eb4e7eeeb09bdf2e1b80984b378c5a8ea9930f04)
12 git clone --depth 1 --branch r/stx.7.0 https://opendev.org/starlingx/fault.git
15 patch -p1 < ../../cgtsclient-insecure.patch
27 source ./admin_openrc.sh
28 export |grep OS_AUTH_URL
29 export |grep OS_USERNAME
30 export |grep OS_PASSWORD
32 docker-compose run --rm --no-deps --entrypoint=pytest api /tests/unit /tests/integration
35 ## Running the tests with a O-Cloud
37 Prerequisite: in case of testing against real ocloud, download openrc file from ocloud dashboard, e.g.
41 docker-compose run --rm --no-deps --entrypoint=pytest api /tests/unit /tests/integration-ocloud
43 docker-compose run --rm --no-deps --entrypoint=pytest api /tests/integration-ocloud --log-level=DEBUG --log-file=/test
47 ## Tear down containers
50 docker-compose down --remove-orphans
53 ## Test with local virtualenv
56 python3.8 -m venv .venv && source .venv/bin/activate
57 pip install -r requirements.txt -c constraints.txt
58 pip install -r requirements-test.txt
60 # pip install -e o2dms -e o2common
62 pytest tests/integration
67 Test O2DMS with docker-compose
68 ==============================
70 ## setup account over INF and get token
74 NAMESPACE="kube-system"
76 cat <<EOF > admin-login.yaml
81 namespace: kube-system
83 apiVersion: rbac.authorization.k8s.io/v1
84 kind: ClusterRoleBinding
88 apiGroup: rbac.authorization.k8s.io
92 - kind: ServiceAccount
94 namespace: kube-system
96 kubectl apply -f admin-login.yaml
97 TOKEN_DATA=$(kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep ${USER} | awk '{print $1}') | grep "token:" | awk '{print $2}')
101 ## setup remote cli to access kubenetes cluster over INF
104 sudo apt-get install -y apt-transport-https
105 echo "deb http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | \
106 sudo tee -a /etc/apt/sources.list.d/kubernetes.list
108 sudo apt-get install -y kubectl
110 source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
111 echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
113 https://get.helm.sh/helm-v3.5.3-linux-amd64.tar.gz
114 tar xvf helm-v3.5.3-linux-amd64.tar.gz
115 sudo cp linux-amd64/helm /usr/local/bin
117 source <(helm completion bash)
118 echo "source <(helm completion bash)" >> ~/.bashrc
122 TOKEN_DATA=<TOKEN_DATA from INF>
126 kubectl config set-cluster inf-cluster --server=https://${OAM_IP}:6443 --insecure-skip-tls-verify
127 kubectl config set-credentials ${USER} --token=$TOKEN_DATA
128 kubectl config set-context ${USER}@inf-cluster --cluster=inf-cluster --user ${USER} --namespace=${NAMESPACE}
129 kubectl config use-context ${USER}@inf-cluster
136 ## setup local repo: o2imsrepo
139 helm repo add chartmuseum https://chartmuseum.github.io/charts
141 helm pull chartmuseum/chartmuseum # download chartmuseum-3.4.0.tgz to local
142 tar zxvf chartmuseum-3.4.0.tgz
144 export NODE_IP=<INF OAM IP>
146 cat <<EOF>chartmuseum-override.yaml
155 helm install chartmuseumrepo chartmuseum/chartmuseum -f chartmuseum-override.yaml
159 helm repo add o2imsrepo http://${NODE_IP}:30330
162 helm repo add bitnami https://charts.bitnami.com/bitnami
165 helm pull bitnami/mysql
166 helm push mysql-8.8.16.tgz o2imsrepo
169 helm install my-release o2imsrepo/mysql
177 ## Verify CFW over INF: Test with cnf firewall-host-netdevice
179 ## Setup host netdevice over INF
182 ssh sysadmin@<inf oam IP>
183 sudo ip link add name veth11 type veth peer name veth12
184 sudo ip link add name veth21 type veth peer name veth22
185 sudo ip link |grep veth
190 ## verify CNF over INF
192 git clone https://github.com/biny993/firewall-host-netdevice.git
194 cat <<EOF> cfw-hostdev-override.yaml
199 pullPolicy: IfNotPresent
206 #global vars for parent and subcharts.
209 unprotectedNetPortVpg: veth11
210 unprotectedNetPortVfw: veth12
211 unprotectedNetCidr: 10.10.1.0/24
212 unprotectedNetGwIp: 10.10.1.1
214 protectedNetPortVfw: veth21
215 protectedNetPortVsn: veth22
216 protectedNetCidr: 10.10.2.0/24
217 protectedNetGwIp: 10.10.2.1
219 vfwPrivateIp0: 10.10.1.1
220 vfwPrivateIp1: 10.10.2.1
222 vpgPrivateIp0: 10.10.1.2
224 vsnPrivateIp0: 10.10.2.2
228 helm install cfw1 firewall-host-netdevice -f cfw-hostdev-override.yaml
233 ## push repo to o2imsrepo
236 tar -zcvf firewall-host-netdevice-1.0.0.tgz firewall-host-netdevice/
237 helm push firewall-host-netdevice-1.0.0.tgz o2imsrepo
239 helm search repo firewall
241 helm install cfw1 o2imsrepo/firewall-host-netdevice -f cfw-hostdev-override.yaml
246 ## build docker image for o2 services
253 ## bootstrap o2 service with docker-compose
256 mkdir -p temp/kubeconfig/
257 cp <your .kube/config> temp/kubeconfig/
259 source ./admin_openrc.sh
260 export K8S_KUBECONFIG=/etc/kubeconfig/config
262 docker logs -f o2_redis_pubsub_1
266 ## simiulate SMO to deploy CFW
270 curl --location --request GET 'http://localhost:5005/o2ims_infrastructureInventory/v1/deploymentManagers'
271 export dmsId=<DMS ID>
272 curl --location --request POST 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor' \
273 --header 'Content-Type: application/json' \
276 "description": "demo nf deployment descriptor",
277 "artifactRepoUrl": "http://128.224.115.15:30330",
278 "artifactName": "firewall-host-netdevice",
280 "{\n \"image\": {\n \"repository\": \"ubuntu\",\n \"tag\": 18.04,\n \"pullPolicy\": \"IfNotPresent\"\n },\n \"resources\": {\n \"cpu\": 2,\n \"memory\": \"2Gi\",\n \"hugepage\": \"256Mi\",\n \"unprotectedNetPortVpg\": \"veth11\",\n \"unprotectedNetPortVfw\": \"veth12\",\n \"unprotectedNetCidr\": \"10.10.1.0/24\",\n \"unprotectedNetGwIp\": \"10.10.1.1\",\n \"protectedNetPortVfw\": \"veth21\",\n \"protectedNetPortVsn\": \"veth22\",\n \"protectedNetCidr\": \"10.10.2.0/24\",\n \"protectedNetGwIp\": \"10.10.2.1\",\n \"vfwPrivateIp0\": \"10.10.1.1\",\n \"vfwPrivateIp1\": \"10.10.2.1\",\n \"vpgPrivateIp0\": \"10.10.1.2\",\n \"vsnPrivateIp0\": \"10.10.2.2\"\n }\n}",
281 "outputParams": "{\"output1\": 100}"
284 curl --location --request GET 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor'
286 curl --location --request POST 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment' \
287 --header 'Content-Type: application/json' \
290 "description": "demo nf deployment",
291 "descriptorId": "<NfDeploymentDescriptorId>",
292 "parentDeploymentId": ""
295 curl --location --request GET 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment'
297 export NfDeploymentId=<NfDeployment Id>
304 docker logs -f o2_redis_pubsub_1
306 kubectl logs -f cfw100-sink-host-netdevice-59bf6fbd4b-845p4
309 ## watch traffic stats
311 open browswer with url: http://<NODE_IP>:30667
317 curl --location --request DELETE 'http://localhost:5005/o2dms/v1/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}'