0440c4beba2ec71a51bb18c784b62d084fb12fd2
[releng.git] / jjb / dovetail / dovetail-run.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 #the noun INSTALLER is used in community, here is just the example to run.
11 #multi-platforms are supported.
12
13 set -e
14 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
15
16 DEPLOY_TYPE=baremetal
17 [[ $BUILD_TAG =~ "virtual" ]] && DEPLOY_TYPE=virt
18
19 DOVETAIL_HOME=${WORKSPACE}/ovp
20 [ -d ${DOVETAIL_HOME} ] && sudo rm -rf ${DOVETAIL_HOME}
21
22 mkdir -p ${DOVETAIL_HOME}
23
24 DOVETAIL_CONFIG=${DOVETAIL_HOME}/pre_config
25 mkdir -p ${DOVETAIL_CONFIG}
26
27 DOVETAIL_IMAGES=${DOVETAIL_HOME}/images
28 mkdir -p ${DOVETAIL_IMAGES}
29
30 OPENRC=${DOVETAIL_CONFIG}/env_config.sh
31 CACERT=${DOVETAIL_CONFIG}/os_cacert
32 POD=${DOVETAIL_CONFIG}/pod.yaml
33
34 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
35
36 sshkey=""
37
38 TEST_DB_URL=http://testresults.opnfv.org/test/api/v1/results
39
40 check_file_exists() {
41     if [[ -f $1 ]]; then
42         echo 0
43     else
44         echo 1
45     fi
46 }
47
48 get_cred_file_with_scripts() {
49     echo "INFO: clone releng repo..."
50     releng_repo=${WORKSPACE}/releng
51     [ -d ${releng_repo} ] && sudo rm -rf ${releng_repo}
52     git clone https://gerrit.opnfv.org/gerrit/releng ${releng_repo} >/dev/null
53
54     echo "INFO: clone pharos repo..."
55     pharos_repo=${WORKSPACE}/pharos
56     [ -d ${pharos_repo} ] && sudo rm -rf ${pharos_repo}
57     git clone https://git.opnfv.org/pharos ${pharos_repo} >/dev/null
58
59     echo "INFO: SUT branch is $SUT_BRANCH"
60     echo "INFO: dovetail branch is $BRANCH"
61     BRANCH_BACKUP=$BRANCH
62     export BRANCH=$SUT_BRANCH
63     cmd="${releng_repo}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} -o ${CACERT} >${redirect}"
64     echo "INFO: cmd is ${cmd}"
65     ${cmd}
66     export BRANCH=$BRANCH_BACKUP
67 }
68
69 get_apex_cred_file() {
70     instack_mac=$(sudo virsh domiflist undercloud | grep default | \
71                   grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
72     INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
73     sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
74     if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
75         #note: this happens only in opnfv-lf-pod1
76         sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
77         sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
78     fi
79     get_cred_file_with_scripts
80 }
81
82 get_compass_cred_file() {
83     get_cred_file_with_scripts
84 }
85
86 get_fuel_cred_file() {
87     get_cred_file_with_scripts
88 }
89
90 get_joid_cred_file() {
91     # If production lab then creds may be retrieved dynamically
92     # creds are on the jumphost, always in the same folder
93     sudo cp $LAB_CONFIG/admin-openrc $OPENRC
94 }
95
96 change_cred_file_cacert_path() {
97     if [[ ${INSTALLER_TYPE} == "apex" ]]; then
98         echo "INFO: apex doesn't need to set OS_CACERT."
99         return 0
100     fi
101     exists=`check_file_exists ${CACERT}`
102     if [[ $exists == 0 ]]; then
103         echo "INFO: set ${INSTALLER_TYPE} openstack cacert file to be ${CACERT}"
104         if [[ ${INSTALLER_TYPE} == "compass" ]]; then
105             echo "export OS_CACERT=${CACERT}" >> ${OPENRC}
106         elif [[ ${INSTALLER_TYPE} == "fuel" ]]; then
107             sed -i "s#/etc/ssl/certs/mcp_os_cacert#${CACERT}#g" ${OPENRC}
108         fi
109     else
110         echo "ERROR: cannot find file ${CACERT}. Please check if it exists."
111         sudo ls -al ${DOVETAIL_CONFIG}
112         exit 1
113     fi
114 }
115
116 change_cred_file_ext_net() {
117     exists=`check_file_exists ${OPENRC}`
118     if [[ $exists == 0 ]]; then
119         echo "export EXTERNAL_NETWORK=${EXTERNAL_NETWORK}" >> ${OPENRC}
120     else
121         echo "ERROR: cannot find file $OPENRC. Please check if it exists."
122         sudo ls -al ${DOVETAIL_CONFIG}
123         exit 1
124     fi
125 }
126
127 get_cred_file() {
128     if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
129         get_apex_cred_file
130     elif [[ ${INSTALLER_TYPE} == 'compass' ]]; then
131         get_compass_cred_file
132     elif [[ ${INSTALLER_TYPE} == 'fuel' ]]; then
133         get_fuel_cred_file
134     elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
135         get_joid_cred_file
136     fi
137
138     exists=`check_file_exists ${OPENRC}`
139     if [[ $exists == 0 ]]; then
140         echo "INFO: original openstack credentials file is:"
141         cat $OPENRC
142         echo "INFO: change cacert file path in credentials file"
143         change_cred_file_cacert_path
144         echo "INFO: set external network in credentials file"
145         change_cred_file_ext_net
146         echo "INFO: final openstack credentials file is:"
147         cat $OPENRC
148     else
149         echo "ERROR: cannot find file $OPENRC. Please check if it exists."
150         sudo ls -al ${DOVETAIL_CONFIG}
151         exit 1
152     fi
153 }
154
155 get_compass_pod_file() {
156     compass_repo=${WORKSPACE}/compass4nfv/
157     echo "INFO: clone compass repo..."
158     git clone https://github.com/opnfv/compass4nfv.git ${compass_repo} >/dev/null
159     scenario_file=${compass_repo}/deploy/conf/hardware_environment/$NODE_NAME/os-nosdn-nofeature-ha.yml
160     ipmiIp=$(cat ${scenario_file} | shyaml get-value hosts.0.ipmiIp)
161     ipmiPass=$(cat ${scenario_file} | shyaml get-value hosts.0.ipmiPass)
162     ipmiUser=root
163     jumpserver_ip=$(ifconfig | grep -A 5 docker0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1)
164
165     cat << EOF >${POD}
166 nodes:
167 - {ip: ${jumpserver_ip}, name: node0, password: root, role: Jumpserver, user: root}
168 - {ip: 10.1.0.50, name: node1, password: root, role: controller, user: root,
169    ipmi_ip: ${ipmiIp}, ipmi_user: ${ipmiUser}, ipmi_password: ${ipmiPass}}
170 - {ip: 10.1.0.51, name: node2, password: root, role: controller, user: root}
171 - {ip: 10.1.0.52, name: node3, password: root, role: controller, user: root}
172 - {ip: 10.1.0.53, name: node4, password: root, role: compute, user: root}
173 - {ip: 10.1.0.54, name: node5, password: root, role: compute, user: root}
174
175 EOF
176
177 }
178
179 get_fuel_baremetal_pod_file() {
180     fuel_ctl_ssh_options="${ssh_options} -i ${SSH_KEY}"
181     ssh_user="ubuntu"
182     fuel_ctl_ip=$(ssh 2>/dev/null ${fuel_ctl_ssh_options} "${ssh_user}@${INSTALLER_IP}" \
183             "sudo salt 'cfg*' pillar.get _param:openstack_control_address --out text| \
184                 cut -f2 -d' '")
185     fuel_cmp_ip=$(ssh 2>/dev/null ${fuel_ctl_ssh_options} "${ssh_user}@${INSTALLER_IP}" \
186             "sudo salt 'cmp001*' pillar.get _param:openstack_control_address --out text| \
187                 cut -f2 -d' '")
188     fuel_dbs_ip=$(ssh 2>/dev/null ${fuel_ctl_ssh_options} "${ssh_user}@${INSTALLER_IP}" \
189             "sudo salt 'dbs01*' pillar.get _param:openstack_database_node01_address --out text| \
190                 cut -f2 -d' '")
191     fuel_msg_ip=$(ssh 2>/dev/null ${fuel_ctl_ssh_options} "${ssh_user}@${INSTALLER_IP}" \
192             "sudo salt 'msg01*' pillar.get _param:openstack_message_queue_node01_address --out text| \
193                 cut -f2 -d' '")
194     ipmi_index=$(ssh 2>/dev/null ${fuel_ctl_ssh_options} "${ssh_user}@${INSTALLER_IP}" \
195             "sudo salt 'ctl*' network.ip_addrs cidr=${fuel_ctl_ip} --out text | grep ${fuel_ctl_ip} | cut -c 5")
196
197     organization="$(cut -d'-' -f1 <<< "${NODE_NAME}")"
198     pod_name="$(cut -d'-' -f2 <<< "${NODE_NAME}")"
199     pdf_file=${pharos_repo}/labs/${organization}/${pod_name}.yaml
200     ipmiIp=$(cat ${pdf_file} | shyaml get-value nodes.$[ipmi_index-1].remote_management.address)
201     ipmiIp="$(cut -d'/' -f1 <<< "${ipmiIp}")"
202     ipmiPass=$(cat ${pdf_file} | shyaml get-value nodes.$[ipmi_index-1].remote_management.pass)
203     ipmiUser=$(cat ${pdf_file} | shyaml get-value nodes.$[ipmi_index-1].remote_management.user)
204     [[ $ipmiUser == ENC* ]] && ipmiUser=$(eyaml decrypt -s ${ipmiUser//[[:blank:]]/})
205     [[ $ipmiPass == ENC* ]] && ipmiPass=$(eyaml decrypt -s ${ipmiPass//[[:blank:]]/})
206
207     cat << EOF >${POD}
208 nodes:
209 - {ip: ${INSTALLER_IP}, name: node0, key_filename: ${DOVETAIL_CONFIG}/id_rsa,
210    role: Jumpserver, user: ${ssh_user}}
211 - {ip: ${fuel_ctl_ip}, name: node1, key_filename: ${DOVETAIL_CONFIG}/id_rsa,
212    role: controller, user: ${ssh_user}, ipmi_ip: ${ipmiIp}, ipmi_user: ${ipmiUser}, ipmi_password: ${ipmiPass}}
213 - {ip: ${fuel_msg_ip}, name: msg01, key_filename: ${DOVETAIL_CONFIG}/id_rsa, role: controller, user: ${ssh_user}}
214 - {ip: ${fuel_cmp_ip}, name: cmp01, key_filename: ${DOVETAIL_CONFIG}/id_rsa, role: controller, user: ${ssh_user}}
215 - {ip: ${fuel_dbs_ip}, name: dbs01, key_filename: ${DOVETAIL_CONFIG}/id_rsa, role: controller, user: ${ssh_user}}
216 EOF
217 }
218
219 get_pod_file_with_scripts() {
220     set +e
221     sudo pip install virtualenv
222
223     cd ${releng_repo}/modules
224     sudo virtualenv venv
225     source venv/bin/activate
226     sudo pip install -e ./ >/dev/null
227     sudo pip install netaddr
228
229     if [[ ${INSTALLER_TYPE} == compass ]]; then
230         options="-u root -p root"
231     elif [[ ${INSTALLER_TYPE} == fuel ]]; then
232         options="-u ubuntu -k /root/.ssh/id_rsa"
233     elif [[ ${INSTALLER_TYPE} == apex ]]; then
234         options="-u stack -k /root/.ssh/id_rsa"
235     elif [[ ${INSTALLER_TYPE} == daisy ]]; then
236         options="-u root -p r00tme"
237     else
238         echo "WARNING: Don't support to generate ${POD} on ${INSTALLER_TYPE} currently."
239         echo "WARNING: HA test cases may not run properly."
240     fi
241
242     cmd="sudo python ${releng_repo}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
243          -i ${INSTALLER_IP} ${options} -f ${POD} \
244          -s ${DOVETAIL_CONFIG}/id_rsa"
245     echo "INFO: cmd is ${cmd}"
246     ${cmd}
247
248     deactivate
249     set -e
250     cd ${WORKSPACE}
251 }
252
253 change_apex_pod_file_process_info() {
254     cat << EOF >> ${POD}
255 process_info:
256 - {testcase_name: yardstick.ha.rabbitmq, attack_process: rabbitmq_server}
257 - {testcase_name: yardstick.ha.cinder_api, attack_process: cinder_wsgi}
258 EOF
259 }
260
261 change_fuel_pod_file_process_info() {
262     cat << EOF >> ${POD}
263 process_info:
264 - {testcase_name: yardstick.ha.cinder_api, attack_process: cinder-wsgi}
265 - {testcase_name: yardstick.ha.rabbitmq, attack_process: rabbitmq_server, attack_host: msg01}
266 - {testcase_name: yardstick.ha.neutron_l3_agent, attack_process: neutron-l3-agent, attack_host: cmp01}
267 - {testcase_name: yardstick.ha.database, attack_process: mysqld, attack_host: dbs01}
268 EOF
269 }
270
271 change_compass_pod_file_process_info() {
272     cat << EOF >> ${POD}
273 process_info:
274 - {testcase_name: yardstick.ha.rabbitmq, attack_process: rabbitmq}
275 EOF
276 }
277
278 change_pod_file_process_info() {
279     sudo chmod 666 ${POD}
280     echo "INFO: adapt process info for $INSTALLER_TYPE ..."
281     if [ "$INSTALLER_TYPE" == "apex" ]; then
282         change_apex_pod_file_process_info
283     elif [ "$INSTALLER_TYPE" == "fuel" ]; then
284         change_fuel_pod_file_process_info
285     elif [ "$INSTALLER_TYPE" == "compass" ]; then
286         change_compass_pod_file_process_info
287     fi
288 }
289
290 get_pod_file() {
291     # These packages are used for parsing yaml files and decrypting ipmi user and password.
292     sudo pip install shyaml
293     sudo yum install -y rubygems || sudo apt-get install -y ruby
294     sudo gem install hiera-eyaml
295     if [[ ${INSTALLER_TYPE} == 'compass' ]]; then
296         get_compass_pod_file
297     elif [[ ${INSTALLER_TYPE} == 'fuel' && ${DEPLOY_TYPE} == 'baremetal' ]]; then
298         get_fuel_baremetal_pod_file
299     fi
300
301     exists=`check_file_exists ${POD}`
302     if [[ $exists == 1 ]]; then
303         get_pod_file_with_scripts
304     fi
305
306     exists=`check_file_exists ${POD}`
307     if [[ $exists == 0 ]]; then
308         change_pod_file_process_info
309     else
310         echo "ERROR: cannot find file ${POD}. Please check if it exists."
311         sudo ls -al ${DOVETAIL_CONFIG}
312         exit 1
313     fi
314
315     echo "INFO: file ${POD} is:"
316     cat ${POD}
317 }
318
319 get_cred_file
320 get_pod_file
321
322 if [ "$INSTALLER_TYPE" == "fuel" ]; then
323     if [[ "${SUT_BRANCH}" =~ "danube" ]]; then
324         echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
325         sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_rsa ${DOVETAIL_CONFIG}/id_rsa
326     else
327         cp ${SSH_KEY} ${DOVETAIL_CONFIG}/id_rsa
328     fi
329 fi
330
331 if [ "$INSTALLER_TYPE" == "apex" ]; then
332     echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
333     sudo scp $ssh_options stack@${INSTALLER_IP}:~/.ssh/id_rsa ${DOVETAIL_CONFIG}/id_rsa
334 fi
335
336 if [ "$INSTALLER_TYPE" == "daisy" ]; then
337     echo "Fetching id_dsa file from jump_server $INSTALLER_IP..."
338     sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_dsa ${DOVETAIL_CONFIG}/id_rsa
339 fi
340
341
342 image_path=${HOME}/opnfv/dovetail/images
343 if [[ ! -d ${image_path} ]]; then
344     mkdir -p ${image_path}
345 fi
346 # sdnvpn test case needs to download this image first before running
347 ubuntu_image=${image_path}/ubuntu-16.04-server-cloudimg-amd64-disk1.img
348 if [[ ! -f ${ubuntu_image} ]]; then
349     echo "Download image ubuntu-16.04-server-cloudimg-amd64-disk1.img ..."
350     wget -q -nc https://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ${image_path}
351 fi
352 sudo cp ${ubuntu_image} ${DOVETAIL_IMAGES}
353
354 # yardstick and bottlenecks need to download this image first before running
355 cirros_image=${image_path}/cirros-0.3.5-x86_64-disk.img
356 if [[ ! -f ${cirros_image} ]]; then
357     echo "Download image cirros-0.3.5-x86_64-disk.img ..."
358     wget -q -nc http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img -P ${image_path}
359 fi
360 sudo cp ${cirros_image} ${DOVETAIL_IMAGES}
361
362 # functest needs to download this image first before running
363 cirros_image=${image_path}/cirros-0.4.0-x86_64-disk.img
364 if [[ ! -f ${cirros_image} ]]; then
365     echo "Download image cirros-0.4.0-x86_64-disk.img ..."
366     wget -q -nc http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img -P ${image_path}
367 fi
368 sudo cp ${cirros_image} ${DOVETAIL_IMAGES}
369
370 # snaps_smoke test case needs to download this image first before running
371 ubuntu14_image=${image_path}/ubuntu-14.04-server-cloudimg-amd64-disk1.img
372 if [[ ! -f ${ubuntu14_image} ]]; then
373     echo "Download image ubuntu-14.04-server-cloudimg-amd64-disk1.img ..."
374     wget -q -nc https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P ${image_path}
375 fi
376 sudo cp ${ubuntu14_image} ${DOVETAIL_IMAGES}
377
378 # cloudify_ims test case needs to download these 2 images first before running
379 cloudify_image=${image_path}/cloudify-manager-premium-4.0.1.qcow2
380 if [[ ! -f ${cloudify_image} ]]; then
381     echo "Download image cloudify-manager-premium-4.0.1.qcow2 ..."
382     wget -q -nc http://repository.cloudifysource.org/cloudify/4.0.1/sp-release/cloudify-manager-premium-4.0.1.qcow2 -P ${image_path}
383 fi
384 sudo cp ${cloudify_image} ${DOVETAIL_IMAGES}
385 trusty_image=${image_path}/trusty-server-cloudimg-amd64-disk1.img
386 if [[ ! -f ${trusty_image} ]]; then
387     echo "Download image trusty-server-cloudimg-amd64-disk1.img ..."
388     wget -q -nc http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img -P ${image_path}
389 fi
390 sudo cp ${trusty_image} ${DOVETAIL_IMAGES}
391
392 opts="--privileged=true -id"
393
394 docker_volume="-v /var/run/docker.sock:/var/run/docker.sock"
395 dovetail_home_volume="-v ${DOVETAIL_HOME}:${DOVETAIL_HOME}"
396
397 # Pull the image with correct tag
398 DOCKER_REPO='opnfv/dovetail'
399 if [ "$(uname -m)" = 'aarch64' ]; then
400     DOCKER_REPO="${DOCKER_REPO}_$(uname -m)"
401     DOCKER_TAG="latest"
402 fi
403
404 echo "Dovetail: Pulling image ${DOCKER_REPO}:${DOCKER_TAG}"
405 docker pull ${DOCKER_REPO}:$DOCKER_TAG >$redirect
406
407 cmd="docker run ${opts} -e DOVETAIL_HOME=${DOVETAIL_HOME} -e INSTALLER_TYPE=${INSTALLER_TYPE} \
408      -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} -e NODE_NAME=${NODE_NAME} -e BUILD_TAG=${BUILD_TAG} \
409      -e TEST_DB_URL=${TEST_DB_URL} -e VERSION=${SUT_BRANCH} \
410      ${docker_volume} ${dovetail_home_volume} \
411      ${sshkey} ${DOCKER_REPO}:${DOCKER_TAG} /bin/bash"
412 echo "Dovetail: running docker run command: ${cmd}"
413 ${cmd} >${redirect}
414 sleep 5
415 container_id=$(docker ps | grep "${DOCKER_REPO}:${DOCKER_TAG}" | awk '{print $1}' | head -1)
416 echo "Container ID=${container_id}"
417 if [ -z ${container_id} ]; then
418     echo "Cannot find ${DOCKER_REPO} container ID ${container_id}. Please check if it exists."
419     docker ps -a
420     exit 1
421 fi
422 echo "Container Start: docker start ${container_id}"
423 docker start ${container_id}
424 sleep 5
425 docker ps >${redirect}
426 if [ $(docker ps | grep "${DOCKER_REPO}:${DOCKER_TAG}" | wc -l) == 0 ]; then
427     echo "The container ${DOCKER_REPO} with ID=${container_id} has not been properly started. Exiting..."
428     exit 1
429 fi
430
431 # Modify tempest_conf.yaml file
432 tempest_conf_file=${DOVETAIL_CONFIG}/tempest_conf.yaml
433 if [[ ${INSTALLER_TYPE} == 'compass' || ${INSTALLER_TYPE} == 'apex' ]]; then
434     volume_device='vdb'
435 else
436     volume_device='vdc'
437 fi
438
439 cat << EOF >$tempest_conf_file
440
441 compute:
442     min_compute_nodes: 2
443     volume_device_name: ${volume_device}
444
445 EOF
446
447 echo "${tempest_conf_file}..."
448 cat ${tempest_conf_file}
449
450 cp_tempest_cmd="docker cp ${DOVETAIL_CONFIG}/tempest_conf.yaml $container_id:/home/opnfv/dovetail/dovetail/userconfig"
451 echo "exec command: ${cp_tempest_cmd}"
452 $cp_tempest_cmd
453
454 if [[ ${TESTSUITE} == 'default' ]]; then
455     testsuite=''
456 else
457     testsuite="--testsuite ${TESTSUITE}"
458 fi
459
460 if [[ ${TESTAREA} == 'mandatory' ]]; then
461     testarea='--mandatory'
462 elif [[ ${TESTAREA} == 'optional' ]]; then
463     testarea="--optional"
464 elif [[ ${TESTAREA} == 'all' ]]; then
465     testarea=""
466 else
467     testarea="--testarea ${TESTAREA}"
468 fi
469
470 run_cmd="dovetail run ${testsuite} ${testarea} --deploy-scenario ${DEPLOY_SCENARIO} -d -r --opnfv-ci"
471 echo "Container exec command: ${run_cmd}"
472 docker exec $container_id ${run_cmd}
473
474 sudo cp -r ${DOVETAIL_HOME}/results ./
475 result_package=$(find ${DOVETAIL_HOME} -name 'logs_*')
476 echo "Results package is ${result_package}"
477 for item in ${result_package};
478 do
479   sudo mv ${item} ./results
480 done
481
482 # To make sure the file owner is the current user, for the copied results files in the above line
483 echo "Change owner of result files ..."
484 CURRENT_USER=${SUDO_USER:-$USER}
485 PRIMARY_GROUP=$(id -gn $CURRENT_USER)
486 echo "Current user is ${CURRENT_USER}, group is ${PRIMARY_GROUP}"
487 sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ./results
488
489 #remove useless files to save disk space
490 sudo rm -rf ./results/workspace
491 sudo rm -f ./results/yardstick.img
492 sudo rm -f ./results/bottlenecks/tmp*
493
494 echo "Dovetail: done!"
495