X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=testsuites%2Frubbos%2Frun_rubbos.py;h=455b3e58ea314357d3789e85d711e49eb51fe4f3;hb=178ce402f58e725bc6c4266be2b5dfee91919dc1;hp=e5f3e5343e8a4827ba9faecb7c6c803d93cbdf3c;hpb=9cae9f39066d07694d94de67761ddbc700f34af0;p=bottlenecks.git diff --git a/testsuites/rubbos/run_rubbos.py b/testsuites/rubbos/run_rubbos.py index e5f3e534..455b3e58 100755 --- a/testsuites/rubbos/run_rubbos.py +++ b/testsuites/rubbos/run_rubbos.py @@ -26,7 +26,7 @@ from novaclient.client import Client as NovaClient parser = argparse.ArgumentParser() parser.add_argument("-c", "--conf", help="configuration files for the testcase, in yaml format", - default="/home/opnfv/bottlenecks/testsuites/rubbos/testcase_cfg/rubbos_1-1-0-1.yaml") + default="/home/opnfv/bottlenecks/testsuites/rubbos/testcase_cfg/rubbos_basic.yaml") args = parser.parse_args() #-------------------------------------------------- @@ -73,7 +73,7 @@ def _download_url(src_url, dest_dir): with open(dest, 'wb') as f: shutil.copyfileobj(response, f) - return file_name + return dest def rubbos_stack_satisfy(name="bottlenecks_rubbos_stack", status="CREATE_COMPLETE"): @@ -129,16 +129,14 @@ def rubbos_env_cleanup(): else: return True -def rubbos_create_images(src_url=None, image_name="bottlenecks_rubbos_image"): +def rubbos_create_images(imagefile=None, image_name="bottlenecks_rubbos_image"): print "========== Create rubbos image in OS ==========" - dest_dir = '/tmp' - file_name = _download_url(src_url, dest_dir) - #file_name = "bottlenecks-trusty-server.img" - if file_name == None: + + if imagefile == None: + print "imagefile not set/found" return False glance = _get_glance_client() - imagefile = dest_dir + "/" + file_name image = glance.images.create(name=image_name, disk_format="qcow2", container_format="bare") with open(imagefile) as fimage: glance.images.upload(image.id, fimage) @@ -195,6 +193,18 @@ def get_instances(nova_client): print "Error [get_instances(nova_client)]:", e return None +def reboot_instances(): + print("========== reboot instances ==========") + nova = _get_nova_client() + print("nova servers list:") + print(nova.servers.list()) + for instance in nova.servers.list(): + name = getattr(instance, 'name') + if name.find("rubbos") >= 0: + print("reboot %s" % name) + instance.reboot() + print("Finish reboot all rubbos servers.") + def rubbos_run(): print "========== run rubbos ===========" @@ -216,18 +226,18 @@ def rubbos_run(): private_ip = [ x['addr'] for x in getattr(instance, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'fixed'] public_ip = [ x['addr'] for x in getattr(instance, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'floating'] - if name.find("rubbos_control") >= 0: + if name.find("rubbos-control") >= 0: control_public_ip = public_ip[0] control_server = str(name) + ':' + public_ip[0] + ':' + private_ip[0] - if name.find("rubbos_client") >= 0: + if name.find("rubbos-client") >= 0: client_servers = client_servers + str(name)+':'+private_ip[0] + "," - if name.find("rubbos_httpd") >= 0: + if name.find("rubbos-httpd") >= 0: web_servers = web_servers + str(name)+':'+private_ip[0] + "," - if name.find("rubbos_tomcat") >= 0: + if name.find("rubbos-tomcat") >= 0: app_servers = app_servers + str(name) + ':' + private_ip[0] + "," - if name.find("rubbos_cjdbc") >= 0: + if name.find("rubbos-cjdbc") >= 0: cjdbc_controller = str(name) + ':' + private_ip[0] - if name.find("rubbos_mysql") >= 0: + if name.find("rubbos-mysql") >= 0: database_servers = database_servers + str(name) + ':' + private_ip[0] + "," client_servers = client_servers[0:len(client_servers)-1] @@ -263,8 +273,25 @@ def rubbos_run(): cmd = "sudo chmod 0600 " + Bottlenecks_repo_dir + "/utils/infra_setup/bottlenecks_key/bottlenecks_key" subprocess.call(cmd, shell=True) - ssh_args = "-o StrictHostKeyChecking=no -o BatchMode=yes -i " + Bottlenecks_repo_dir + "/utils/infra_setup/bottlenecks_key/bottlenecks_key " + + print "############### Test #################" + cmd = 'ssh-keygen -f "/root/.ssh/known_hosts" -R ' + control_public_ip + subprocess.call(cmd, shell=True) + print "## Ping test:" + cmd = "ping -c 5 " + control_public_ip + print cmd + subprocess.call(cmd, shell=True) + print "## ssh date test:" + cmd = "ssh " + ssh_args + " ubuntu@" + control_public_ip + ' "date"' + print cmd + subprocess.call(cmd, shell=True) + print "## neutruon net-list:" + subprocess.call("neutron net-list", shell=True) + print "## nova list:" + subprocess.call("nova list", shell=True) + print "############### Test #################" + cmd = "scp " + ssh_args + "rubbos.conf ubuntu@" + control_public_ip + ":/home/ubuntu/" print "Exec shell: " + cmd subprocess.call(cmd, shell=True) @@ -297,23 +324,23 @@ def main(): global image_url Bottlenecks_repo_dir = "/home/opnfv/bottlenecks" # same in Dockerfile, docker directory - #image_url = 'http://artifacts.opnfv.org/bottlenecks/rubbos/trusty-server-cloudimg-amd64-btnks.img' - image_url = 'http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img' + image_url = 'http://artifacts.opnfv.org/bottlenecks/rubbos/trusty-server-cloudimg-amd64-btnks.img' + #image_url = 'http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img' if not (args.conf): logger.error("Configuration files are not set for testcase") exit(-1) else: Heat_template = args.conf - + master_user_data="" agent_user_data="" with open(Bottlenecks_repo_dir+"/utils/infra_setup/user_data/p-master-user-data") as f: master_user_data=f.read() - master_user_data = master_user_data.replace('REPLACED_PUPPET_MASTER_SERVER','rubbos_control') + master_user_data = master_user_data.replace('REPLACED_PUPPET_MASTER_SERVER','rubbos-control') with open(Bottlenecks_repo_dir+"/utils/infra_setup/user_data/p-agent-user-data") as f: agent_user_data=f.read() - agent_user_data = agent_user_data.replace('REPLACED_PUPPET_MASTER_SERVER','rubbos_control') + agent_user_data = agent_user_data.replace('REPLACED_PUPPET_MASTER_SERVER','rubbos-control') parameters={'image': 'bottlenecks_rubbos_image', 'key_name': 'bottlenecks_rubbos_keypair', @@ -331,7 +358,13 @@ def main(): rubbos_env_prepare(Heat_template) rubbos_env_cleanup() - image_created = rubbos_create_images(image_url) + dest_dir = "/tmp" + image_file = _download_url(image_url, dest_dir) + if image_file == None: + print "error with downloading image(s)" + exit(-1) + + image_created = rubbos_create_images(imagefile=image_file) keyPath = Bottlenecks_repo_dir + "/utils/infra_setup/bottlenecks_key/bottlenecks_key.pub" rubbos_create_keypairs(key_path=keyPath) rubbos_create_flavors() @@ -342,7 +375,15 @@ def main(): print "Cannot create instances, as Failed to create image(s)." exit (-1) + print "Wait 600 seconds after stack creation..." + time.sleep(600) + + #reboot_instances() + #time.sleep(180) + rubbos_run() + time.sleep(30) + rubbos_env_cleanup() if __name__=='__main__':