diff options
author | Peter Mikus <pmikus@cisco.com> | 2017-10-12 09:06:58 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2017-10-16 08:55:52 +0000 |
commit | fcaf06abdd27a3a6ef18de14ce3d1dab2c75a8c9 (patch) | |
tree | 2561f791fbb9a07168428f6ab7ed8a55d4996135 | |
parent | 9a261ea61549fc6a5c23369d2e236b002dc35038 (diff) |
CSIT-841 Optimize creating of vnf-agent docker image Part I
- Optimize building of prod_vpp_agent docker image by using
dev_vpp_agent docker image pulled from dockerhub/ligato instead of
building on slave.
- Add detailed logs from every POD deployed in namespace.
- Hardening condition for considering PODs Running.
Change-Id: I9f771d6365d38fef2ec2e00ab642853e6a44ad03
Signed-off-by: Peter Mikus <pmikus@cisco.com>
-rw-r--r-- | LIGATO_STABLE_VER | 1 | ||||
-rw-r--r-- | VPP_AGENT_STABLE_VER | 1 | ||||
-rw-r--r-- | bootstrap-verify-perf-ligato.sh | 82 | ||||
-rw-r--r-- | resources/libraries/python/KubernetesUtils.py | 34 | ||||
-rw-r--r-- | resources/tools/scripts/topo_container_copy.py | 9 | ||||
-rw-r--r-- | tests/ligato/perf/l2/10ge2p1x520-eth-l2bdbase-eth-2memif-1vnf-ndrpdrdisc.robot | 1 | ||||
-rw-r--r-- | tests/ligato/perf/l2/10ge2p1x520-eth-l2xcbase-eth-2memif-1vnf-ndrpdrdisc.robot | 1 |
7 files changed, 114 insertions, 15 deletions
diff --git a/LIGATO_STABLE_VER b/LIGATO_STABLE_VER deleted file mode 100644 index ce15bd91e3..0000000000 --- a/LIGATO_STABLE_VER +++ /dev/null @@ -1 +0,0 @@ -8b61778490fa4a22df294b0682c13e39b8f51869 diff --git a/VPP_AGENT_STABLE_VER b/VPP_AGENT_STABLE_VER new file mode 100644 index 0000000000..849f17f4d1 --- /dev/null +++ b/VPP_AGENT_STABLE_VER @@ -0,0 +1 @@ +v1.0.5-2-g0c0f202 diff --git a/bootstrap-verify-perf-ligato.sh b/bootstrap-verify-perf-ligato.sh index 7c4c6d3962..f00183fe5a 100644 --- a/bootstrap-verify-perf-ligato.sh +++ b/bootstrap-verify-perf-ligato.sh @@ -29,10 +29,65 @@ PYBOT_ARGS="-W 150 -L TRACE" ARCHIVE_ARTIFACTS=(log.html output.xml report.html output_perf_data.xml) +# If we run this script from CSIT jobs we want to use stable vpp version +if [[ ${JOB_NAME} == csit-* ]] ; +then + mkdir -p vpp/build-root + cd vpp/build-root + + if [[ ${TEST_TAG} == *NIGHTLY ]] || \ + [[ ${TEST_TAG} == *DAILY ]] || \ + [[ ${TEST_TAG} == *WEEKLY ]]; + then + # Download the latest VPP build .deb install packages + echo Downloading VPP packages... + bash ${SCRIPT_DIR}/resources/tools/scripts/download_install_vpp_pkgs.sh --skip-install + + VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )" + # Take vpp package and get the vpp version + VPP_STABLE_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )" + else + DPDK_STABLE_VER=$(cat ${SCRIPT_DIR}/DPDK_STABLE_VER)_amd64 + VPP_REPO_URL=$(cat ${SCRIPT_DIR}/VPP_REPO_URL_UBUNTU) + VPP_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_STABLE_VER_UBUNTU) + VPP_CLASSIFIER="-deb" + # Download vpp build from nexus and set VPP_DEBS variable + wget -q "${VPP_REPO_URL}/vpp/${VPP_STABLE_VER}/vpp-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + wget -q "${VPP_REPO_URL}/vpp-dbg/${VPP_STABLE_VER}/vpp-dbg-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + wget -q "${VPP_REPO_URL}/vpp-dev/${VPP_STABLE_VER}/vpp-dev-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + # Temporary disable using dpdk + # wget -q "${VPP_REPO_URL}/vpp-dpdk-dkms/${DPDK_STABLE_VER}/vpp-dpdk-dkms-${DPDK_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + wget -q "${VPP_REPO_URL}/vpp-lib/${VPP_STABLE_VER}/vpp-lib-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + wget -q "${VPP_REPO_URL}/vpp-plugins/${VPP_STABLE_VER}/vpp-plugins-${VPP_STABLE_VER}${VPP_CLASSIFIER}.deb" || exit + VPP_DEBS="$( readlink -f *.deb | tr '\n' ' ' )" + fi + + # Temporary workaround as ligato docker file requires specific file name + rename -v 's/^(.*)-(\d.*)-deb.deb/$1_$2.deb/' *.deb + cd ${SCRIPT_DIR} + +# If we run this script from vpp project we want to use local build +elif [[ ${JOB_NAME} == vpp-* ]] ; +then + mkdir -p vpp/build-root + # Use local packages provided as argument list + # Jenkins VPP deb paths (convert to full path) + VPP_DEBS="$( readlink -f $@ | tr '\n' ' ' )" + # Take vpp package and get the vpp version + VPP_STABLE_VER="$( expr match $1 'vpp-\(.*\)-deb.deb' )" + # Move files to build-root for packing + for deb in ${VPP_DEBS}; do mv ${deb} vpp/build-root/; done +else + echo "Unable to identify job type based on JOB_NAME variable: ${JOB_NAME}" + exit 1 +fi + +# Compress all VPP debs and remove temporary directory +tar -zcvf ${SCRIPT_DIR}/vpp.tar.gz vpp/* && rm -R vpp + LIGATO_REPO_URL=$(cat ${SCRIPT_DIR}/LIGATO_REPO_URL) -LIGATO_STABLE_VER=$(cat ${SCRIPT_DIR}/LIGATO_STABLE_VER) -VPP_COMMIT=$1 -VPP_BUILD=$1 +VPP_AGENT_STABLE_VER=$(cat ${SCRIPT_DIR}/VPP_AGENT_STABLE_VER) +VPP_AGENT_STABLE_COMMIT="$( expr match `cat VPP_AGENT_STABLE_VER` '.*g\(.*\)' )" DOCKER_DEB="docker-ce_17.06.2~ce-0~ubuntu_amd64.deb" # Clone & checkout stable vnf-agent @@ -42,10 +97,10 @@ if [ $? != 0 ]; then echo "Failed to run: git clone --depth 1 ${LIGATO_REPO_URL}/vpp-agent" exit 1 fi -cd vpp-agent && git checkout ${LIGATO_STABLE_VER} +cd vpp-agent && git checkout ${VPP_AGENT_STABLE_COMMIT} # If the git checkout fails, complain clearly and exit if [ $? != 0 ]; then - echo "Failed to run: git checkout ${LIGATO_STABLE_VER}" + echo "Failed to run: git checkout ${VPP_AGENT_STABLE_VER}" exit 1 fi @@ -58,12 +113,17 @@ if [ $? != 0 ]; then exit 1 fi -# Compile vnf-agent docker image -cd ${SCRIPT_DIR}/../vpp-agent/docker/dev_vpp_agent/ &&\ - ./build.sh --agent ${LIGATO_STABLE_VER} --vpp ${VPP_COMMIT} &&\ - ./shrink.sh +# Pull ligato/dev_vpp_agent docker image and re-tag as local +sudo docker pull ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER} +sudo docker tag ligato/dev-vpp-agent:${VPP_AGENT_STABLE_VER}\ + dev_vpp_agent:latest +sudo docker images + +# Build prod_vpp_agent docker image cd ${SCRIPT_DIR}/../vpp-agent/docker/prod_vpp_agent/ &&\ - ./build.sh &&\ + mv ${SCRIPT_DIR}/vpp.tar.gz . &&\ + ./extract_agent_files.sh &&\ + sudo docker build -t prod_vpp_agent --no-cache . &&\ ./shrink.sh # Export Docker image sudo docker save prod_vpp_agent_shrink | gzip > prod_vpp_agent_shrink.tar.gz @@ -347,7 +407,7 @@ echo Post-processing test data... python ${SCRIPT_DIR}/resources/tools/scripts/robot_output_parser.py \ -i ${SCRIPT_DIR}/output.xml \ -o ${SCRIPT_DIR}/output_perf_data.xml \ - -v ${VPP_BUILD} + -v ${VPP_STABLE_VER} if [ ! $? -eq 0 ]; then echo "Parsing ${SCRIPT_DIR}/output.xml failed" fi diff --git a/resources/libraries/python/KubernetesUtils.py b/resources/libraries/python/KubernetesUtils.py index 5faa056ddc..77628b64d8 100644 --- a/resources/libraries/python/KubernetesUtils.py +++ b/resources/libraries/python/KubernetesUtils.py @@ -244,6 +244,36 @@ class KubernetesUtils(object): rtype) @staticmethod + def get_kubernetes_logs_on_node(node, namespace='csit'): + """Get Kubernetes logs on node. + + :param node: DUT node. + :param namespace: Kubernetes namespace. + :type node: dict + :type namespace: str + """ + ssh = SSH() + ssh.connect(node) + + cmd = "for p in $(kubectl get pods -n {namespace} --no-headers"\ + " | cut -f 1 -d ' '); do echo $p; kubectl logs -n {namespace} $p; "\ + "done".format(namespace=namespace) + ssh.exec_command(cmd, timeout=120) + + @staticmethod + def get_kubernetes_logs_on_all_duts(nodes, namespace='csit'): + """Get Kubernetes logs on all DUTs. + + :param nodes: Topology nodes. + :param namespace: Kubernetes namespace. + :type nodes: dict + :type namespace: str + """ + for node in nodes.values(): + if node['type'] == NodeType.DUT: + KubernetesUtils.get_kubernetes_logs_on_node(node, namespace) + + @staticmethod def reset_kubernetes_on_node(node): """Reset Kubernetes on node. @@ -288,7 +318,9 @@ class KubernetesUtils(object): if int(ret_code) == 0: ready = True for line in stdout.splitlines(): - if 'Running' not in line: + if 'Running' in line and '1/1' in line: + ready = True + else: ready = False if ready: break diff --git a/resources/tools/scripts/topo_container_copy.py b/resources/tools/scripts/topo_container_copy.py index d243182236..088b7a4386 100644 --- a/resources/tools/scripts/topo_container_copy.py +++ b/resources/tools/scripts/topo_container_copy.py @@ -122,11 +122,16 @@ def main(): ssh.scp(local_path=image, remote_path=directory) # Load image to Docker. - cmd = "for f in {directory}/*.tar.gz; do zcat $f | "\ - "sudo docker load; done".format(directory=directory) + cmd = "for f in {directory}/*.tar.gz; do "\ + "sudo docker load -i $f; done".format(directory=directory) stdout = ssh_no_error(ssh, cmd) print("###TI {}".format(stdout)) + # Remove <none> images from Docker. + cmd = "docker rmi $(sudo docker images -f 'dangling=true' -q)" + stdout = ssh_no_error(ssh, cmd, sudo=True) + print("###TI {}".format(stdout)) + if __name__ == "__main__": sys.exit(main()) diff --git a/tests/ligato/perf/l2/10ge2p1x520-eth-l2bdbase-eth-2memif-1vnf-ndrpdrdisc.robot b/tests/ligato/perf/l2/10ge2p1x520-eth-l2bdbase-eth-2memif-1vnf-ndrpdrdisc.robot index 277c3ab199..cfc74c37f0 100644 --- a/tests/ligato/perf/l2/10ge2p1x520-eth-l2bdbase-eth-2memif-1vnf-ndrpdrdisc.robot +++ b/tests/ligato/perf/l2/10ge2p1x520-eth-l2bdbase-eth-2memif-1vnf-ndrpdrdisc.robot @@ -28,6 +28,7 @@ | Suite Teardown | Tear down 3-node performance topology | ... | Test Teardown | Run Keywords +| ... | Get Kubernetes logs on all DUTs | ${nodes} | AND | ... | Describe Kubernetes resource on all DUTs | ${nodes} | AND | ... | Delete Kubernetes resource on all duts | ${nodes} | ... diff --git a/tests/ligato/perf/l2/10ge2p1x520-eth-l2xcbase-eth-2memif-1vnf-ndrpdrdisc.robot b/tests/ligato/perf/l2/10ge2p1x520-eth-l2xcbase-eth-2memif-1vnf-ndrpdrdisc.robot index 6dba66fbcf..759065b389 100644 --- a/tests/ligato/perf/l2/10ge2p1x520-eth-l2xcbase-eth-2memif-1vnf-ndrpdrdisc.robot +++ b/tests/ligato/perf/l2/10ge2p1x520-eth-l2xcbase-eth-2memif-1vnf-ndrpdrdisc.robot @@ -28,6 +28,7 @@ | Suite Teardown | Tear down 3-node performance topology | ... | Test Teardown | Run Keywords +| ... | Get Kubernetes logs on all DUTs | ${nodes} | AND | ... | Describe Kubernetes resource on all DUTs | ${nodes} | AND | ... | Delete Kubernetes resource on all duts | ${nodes} | ... |