54d262af4886955e64c70132b1c1c78ed61f6d52
[kvmfornfv.git] / ci / envs / host-config
1 #!/bin/bash
2
3 ##############################################################################
4 ## Copyright (c) 2015 Intel Corp.
5 ##
6 ## All rights reserved. This program and the accompanying materials
7 ## are made available under the terms of the Apache License, Version 2.0
8 ## which accompanies this distribution, and is available at
9 ## http://www.apache.org/licenses/LICENSE-2.0
10 ###############################################################################
11
12 # Number of huge pages to create and on which NUMA node
13 numa_node=1
14 huge_pages=2
15
16 # QEMU executable path and number of cpus for guest
17 qemu=/usr/local/bin/qemu-system-x86_64
18 guest_cpus=2
19 pcm_memory=/root/pcm/pcm-memory.x
20
21 # Isolated cpus for nfv, must be given as a range '-' and Numa node1 CPU's should be considered
22 host_isolcpus=`lscpu | grep "NUMA node1 CPU(s)"| awk -F ':' '{print \$2}' | sed 's/[[:space:]]//g'`
23 first=$(echo ${host_isolcpus} | cut -f1 -d-)
24 last=$(echo ${host_isolcpus} | cut -f2 -d- | cut -d',' -f1 )
25
26 # Bind cpus from host_isolcpus range for QEMU processor threads
27 i=0
28 while [ ${i} -lt ${guest_cpus} ]; do
29  qemu_cpu[$i]=${first}
30  i=`expr $i + 1`
31  first=`expr $first + 1`
32 done
33
34 #Isolated cpus from host_isolcpus range to run Stress tool
35 stress_isolcpus=${first}-${last}
36 echo "Stress tool runs on $stress_isolcpus"
37
38 #Host for executing test cases based on test_type/job from releng
39 function setHostIP {
40    test_type=$1
41    if [ ${test_type} == "verify" ];then
42       HOST_IP="10.10.100.21"
43    elif [ ${test_type} == "daily" ];then
44       HOST_IP="10.10.100.22"
45    else
46       echo "Incorrect test type"
47    fi
48    echo ${HOST_IP}
49 }
50
51 #Time duration for executing test cases based on test_type/job from releng
52 function setTestTime {
53    test_type=$1
54    if [ ${test_type} == "verify" ];then
55       test_time=120000 # 2m
56    elif [ ${test_type} == "daily" ];then
57       test_time=3600000 # 1hr
58    else
59       echo "Incorrect test type"
60    fi
61    echo ${test_time}
62 }
63
64 #Tar the log files generated during testcase execution and exit.
65 function test_exit {
66    exitCode=$1
67    cd $WORKSPACE/build_output/
68    if [ -d log ];then
69       tar -czvf log-$(date -u +"%Y-%m-%d_%H-%M-%S").tar.gz log
70    fi
71    exit $exitCode
72 }
73
74 function copyLogs {
75    echo "Copying Log files from Node to Jump Server"
76    sudo ssh root@${HOST_IP} "cd /root;tar -czvf MBWInfo.tar.gz MBWInfo"
77    mkdir -p $WORKSPACE/build_output/log/MBWInfo
78    scp root@${HOST_IP}:/root/MBWInfo.tar.gz $WORKSPACE/build_output/log/MBWInfo
79    echo "Listing all the logs collected"
80    cd $WORKSPACE;ls build_output/log/MBWInfo;
81    sudo ssh root@${HOST_IP} "cd /root;rm -rf MBWInfo MBWInfo.tar.gz"
82 }
83
84 function packet_fwd_logs {
85    #Tar and copy logs for uploading to artifacts repository
86    echo "Copying Log files from Node to Jump Server"
87    mkdir -p $WORKSPACE/build_output/log/packet_fwd
88    scp -r root@${HOST_IP}:/tmp/packet_fwd_logs $WORKSPACE/build_output/log/packet_fwd
89    #removing collected logs on the node after copying.
90    sudo ssh root@${HOST_IP} "cd /tmp;rm -rf packet_fwd_logs"
91 }
92
93 function packet_fwd_exit {
94    exitCode=$1
95    TIMESTAMP=$(date -u +"%Y-%m-%d_%H-%M-%S")
96    cd $WORKSPACE/build_output/
97    if [ -d log ];then
98       tar -czvf log-${TIMESTAMP}.tar.gz log
99       echo "Uploading packet forwarding logs and results"
100       gsutil cp -r log-*.tar.gz gs://artifacts.opnfv.org/kvmfornfv/packet_fwd_${TIMESTAMP} > $WORKSPACE/build_output/gsutil.log 2>&1
101       echo "http://artifacts.opnfv.org/kvmfornfv/packet_fwd_${TIMESTAMP}"
102    fi
103    exit $exitCode
104 }