Skip to content

Commit 3c114fc

Browse files
author
Ruomeng Hao
authored
Merge pull request #37 from ruomengh/fix-ci
Fix ccnp example deployment and E2E test
2 parents f52232e + 5f962e6 commit 3c114fc

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

.github/workflows/e2e-test-k8s.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/[email protected]
1919
- name: Build and push CCNP images
2020
run: |
21-
sudo ./container/build.sh -r gar-registry.caas.intel.com/cpio -g latest -c ccnp-server ccnp-example ccnp-device-plugin
21+
sudo ./container/build.sh -r gar-registry.caas.intel.com/cpio -g latest
2222
- name: Deploy CCNP server
2323
run: |
2424
sudo ./deployment/kubernetes/script/deploy-ccnp.sh -r gar-registry.caas.intel.com/cpio -g latest -d

container/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ function publish_images {
165165
if [[ "$container" == "all" ]]; then
166166
for item in "${all_containers[@]}"
167167
do
168+
if [[ ${item} != "pccs" && ${item} != "qgs" ]] || [[ ${item} == "pccs" && ${pccs} == true ]] || [[ ${item} == "qgs" && ${qgs} == true ]] ; then
168169
publish_a_image "$item"
170+
fi
169171
done
170172
else
171173
publish_a_image "$container"

container/ccnp-example/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ COPY --from=golang-builder /go/ccnp-sdk/example/go-sdk-example ./
3737
COPY --from=rust-builder ccnp-sdk/example/target/release/rust-sdk-example ./
3838

3939
RUN apk update && apk add bash vim tar wget
40-
RUN pip install ./cctrusted_base*.whl ./ccnp*.whl && rm -f *.whl
40+
RUN pip install ./cctrusted_base*.whl ./ccnp*.whl pytest && rm -f *.whl
4141

4242
ENTRYPOINT ["tail", "-f", "/dev/null"]

deployment/kubernetes/script/deploy-ccnp-example.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e
55

66
DEFAULT_DOCKER_REPO=docker.io/library
77
DEFAULT_TAG=latest
8+
WORK_DIR=$(cd "$(dirname "$0")" || exit; pwd)
89
TEMP_MANIFEST_FILE=/tmp/ccnp-example-deployment.yaml
910
DELETE_DEPLOYMENT=false
1011

@@ -23,24 +24,27 @@ while getopts ":r:g:i:dmervh" option; do
2324
done
2425

2526
echo "Deploy CCNP example for container measurement in Kubernetes"
27+
pushd "${WORK_DIR}/../../.." || exit
2628
# replace registry and image tag according to user input
27-
cp ../manifests/ccnp-example-deployment.yaml $TEMP_MANIFEST_FILE
29+
cp deployment/kubernetes/manifests/ccnp-example-deployment.yaml $TEMP_MANIFEST_FILE
2830
if [[ -n "$registry" ]]; then
2931
sed -i "s#${DEFAULT_DOCKER_REPO}#${registry}#g" $TEMP_MANIFEST_FILE
3032
fi
3133
if [[ -n "$tag" ]];then
3234
sed -i "s#${DEFAULT_TAG}#${tag}#g" $TEMP_MANIFEST_FILE
3335
fi
3436

35-
if [ $DELETE_DEPLOYMENT == true ]
36-
then
37+
# Delete old pod if it exists
38+
OLD_POD_NAME=$(kubectl get po -n ccnp | grep ccnp-example | grep Running | awk '{ print $1 }')
39+
40+
if [[ $DELETE_DEPLOYMENT == true ]] && [[ -n "$OLD_POD_NAME" ]]; then
3741
echo "==> Cleaning up ccnp-example deployment"
38-
kubectl delete -f $TEMP_MANIFEST_FILE
42+
kubectl delete deployment ccnp-example -n ccnp
3943
fi
4044

4145
echo "==> Creating ccnp-example deployment"
4246
kubectl apply -f $TEMP_MANIFEST_FILE
43-
for i in {1..5}
47+
for i in {1..10}
4448
do
4549
POD_NAME=$(kubectl get po -n ccnp | grep ccnp-example | grep Running | awk '{ print $1 }')
4650
if [[ -z "$POD_NAME" ]]
@@ -57,3 +61,5 @@ if [[ -z "$POD_NAME" ]]; then
5761
exit 1
5862
fi
5963
echo "CCNP example pod $POD_NAME is Running."
64+
65+
popd || exit

test/ci-test/ci-e2e-test.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
set -o errexit
77

8-
PY_WORK_DIR='test/ci-test/py-test'
8+
PY_WORK_DIR='/run/ccnp/ci-test/py-test'
99

1010
for i in {1..3}
1111
do
12-
POD_NAME=$(kubectl get po | grep ccnp-example | grep Running | awk '{ print $1 }')
12+
POD_NAME=$(kubectl get po -n ccnp | grep ccnp-example | grep Running | awk '{ print $1 }')
1313
if [[ -z "$POD_NAME" ]]
1414
then
1515
sleep 2
@@ -27,12 +27,12 @@ fi
2727

2828
# Run python tests
2929
echo "--------> Run python test........."
30-
kubectl exec -it "$POD_NAME" -- pytest -v ${PY_WORK_DIR}
30+
kubectl exec -it "$POD_NAME" -n ccnp -- pytest -v ${PY_WORK_DIR}
3131

3232
# Run go tests
3333
echo "--------> Run go test........."
34-
kubectl exec -it "$POD_NAME" -- ./go-sdk-example
34+
kubectl exec -it "$POD_NAME" -n ccnp -- ./go-sdk-example
3535

3636
# Run rust tests
3737
echo "--------> Run rust test........."
38-
kubectl exec -it "$POD_NAME" -- ./rust-sdk-example
38+
kubectl exec -it "$POD_NAME" -n ccnp -- ./rust-sdk-example

0 commit comments

Comments
 (0)