aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/OpenStack/vPing/vping.py
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-08-22 07:14:00 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-08-22 07:14:00 +0000
commit9702e358bc92cb2a3f57d78d61cb2ff5a3379622 (patch)
treeba69633e75f44cfe55206b6a0f6747d1ad54f796 /testcases/OpenStack/vPing/vping.py
parent637cb9391f8f8467a3e68288e6252377bf0f2b80 (diff)
parent1da5dd1c5a8b3d3f72086a56a0d525f50199db8b (diff)
Merge "refactor vping"
Diffstat (limited to 'testcases/OpenStack/vPing/vping.py')
-rwxr-xr-xtestcases/OpenStack/vPing/vping.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/testcases/OpenStack/vPing/vping.py b/testcases/OpenStack/vPing/vping.py
new file mode 100755
index 000000000..039e7ec5a
--- /dev/null
+++ b/testcases/OpenStack/vPing/vping.py
@@ -0,0 +1,101 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2015 All rights reserved
+# This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# 0.1: This script boots the VM1 and allocates IP address from Nova
+# Later, the VM2 boots then execute cloud-init to ping VM1.
+# After successful ping, both the VMs are deleted.
+# 0.2: measure test duration and publish results under json format
+# 0.3: adapt push 2 DB after Test API refacroting
+#
+#
+import datetime
+import time
+
+import argparse
+import functest.utils.functest_logger as ft_logger
+
+import vping_util as util
+
+parser = argparse.ArgumentParser()
+image_exists = False
+
+parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
+parser.add_argument("-r", "--report",
+ help="Create json result file",
+ action="store_true")
+parser.add_argument("-m", "--mode", default='ssh',
+ help="vPing mode: userdata or ssh",
+ action="store")
+
+args = parser.parse_args()
+
+""" logging configuration """
+logger = ft_logger.Logger("vping_userdata").getLogger()
+
+
+def main():
+ if args.mode == 'ssh':
+ case = 'vping_ssh'
+ else:
+ case = 'vping_userdata'
+
+ util.init(logger)
+
+ util.check_repo_exist()
+
+ vmname_1 = util.get_vmname_1()
+ vmname_2 = util.get_vmname_2()
+
+ global image_exists
+ image_exists, image_id = util.create_image()
+
+ flavor = util.get_flavor()
+
+ network_id = util.create_network_full()
+
+ sg_id = util.create_security_group()
+
+ util.delete_exist_vms()
+
+ start_time = time.time()
+ logger.info("vPing Start Time:'%s'" % (
+ datetime.datetime.fromtimestamp(start_time).strftime(
+ '%Y-%m-%d %H:%M:%S')))
+
+ vm1 = util.boot_vm(case,
+ vmname_1,
+ image_id,
+ flavor,
+ network_id,
+ None,
+ sg_id)
+ test_ip = util.get_test_ip(vm1)
+ vm2 = util.boot_vm(case,
+ vmname_2,
+ image_id,
+ flavor,
+ network_id,
+ test_ip,
+ sg_id)
+
+ EXIT_CODE, stop_time = util.do_vping(case, vm2, test_ip)
+ details = util.check_result(EXIT_CODE,
+ start_time,
+ stop_time)
+ util.push_result(args.report,
+ case,
+ start_time,
+ stop_time,
+ details)
+
+ exit(EXIT_CODE)
+
+
+if __name__ == '__main__':
+ main()