From cd2f408b4a460f99100dc11665334fdf2f281f78 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Wed, 5 Dec 2018 10:06:28 +0800 Subject: [PATCH] vm_factory: add tests to check new vm time Make sure it is not affected by being created from vm template. Fixes: #968 Signed-off-by: Peng Tao --- integration/vm_factory/vm_templating_test.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/integration/vm_factory/vm_templating_test.sh b/integration/vm_factory/vm_templating_test.sh index 950501d20..740d3268d 100755 --- a/integration/vm_factory/vm_templating_test.sh +++ b/integration/vm_factory/vm_templating_test.sh @@ -70,10 +70,19 @@ check_vm_template_network_setup() { [[ ${IPADDR} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] || die "vm eth0 ip is ${IPADDR}" } +check_new_guest_date_time() { + HOSTTIME=$(date +%s) + GUESTTIME=$(sudo docker exec $CONTAINER_NAME date +%s) + [[ ${HOSTTIME} -le ${GUESTTIME} ]] || die "hosttime ${HOSTTIME} guesttime ${GUESTTIME}" +} + test_create_container_with_vm_template() { + # sleep a bit so that template VM time is in the past + sleep 2 sudo docker run --runtime=$RUNTIME -d --name $CONTAINER_NAME $IMAGE $PAYLOAD_ARGS check_qemu_for_vm_template check_vm_template_network_setup + check_new_guest_date_time sudo docker rm -f $CONTAINER_NAME }