quota limit for posca_stress_ping 31/29131/1
authorliyin <liyin11@huawei.com>
Tue, 21 Feb 2017 09:20:28 +0000 (17:20 +0800)
committerliyin <liyin11@huawei.com>
Tue, 21 Feb 2017 09:30:04 +0000 (17:30 +0800)
JIRA:BOTTLENECK-140

Those code will update an action of quota.
Before out test begin we will make quota no limit.
so we could do stress test.
Those quota limit will change openstack forever.
maybe will create damage for openstack.

Change-Id: I0a6a06c6c303589881cb2ab7b754213ecf1a845f
Signed-off-by: liyin <liyin11@huawei.com>
docker/bottleneck-compose/docker-compose.yml
testsuites/posca/testcase_cfg/posca_stress_ping.yaml
testsuites/posca/testcase_script/posca_stress_ping.py
utils/env_prepare/quota_prepare.py [new file with mode: 0644]
utils/env_prepare/stack_prepare.py

index 6dbf899..7745f41 100644 (file)
@@ -36,3 +36,4 @@ bottlenecks:
   environment:
     - INSTALLER_IP=192.168.200.2
     - INSTALLER_TYPE=compass
+    - DEBUG=true
index a60a883..75eba97 100644 (file)
@@ -7,7 +7,7 @@ load_manager:
     tool: ping
     test_times: 100
     package_size:
-    num_stack: 2, 5, 10
+    num_stack: 5, 10, 20
     package_loss: 10%
 
   contexts:
index 02244a3..732422e 100644 (file)
@@ -18,8 +18,9 @@ import os
 import multiprocessing
 import docker
 import datetime
-import utils.infra_setup.runner.yardstick as Runner
 from utils.parser import Parser as conf_parser
+import utils.env_prepare.quota_prepare as quota_prepare
+import utils.env_prepare.stack_prepare as stack_prepare
 import testsuites.posca.testcase_dashboard.posca_stress_ping as DashBoard
 # --------------------------------------------------
 # logging configuration
@@ -40,9 +41,12 @@ testcase, file_format = os.path.splitext(testfile)
 
 
 def env_pre(con_dic):
+    stack_prepare._prepare_env_daemon()
+    quota_prepare.quota_env_prepare()
     client = docker.from_env()
     con = client.containers.get('bottleneckcompose_yardstick_1')
     cmd = ('yardstick env prepare')
+    LOG.info("yardstick envrionment prepare!")
     stdout = con.exec_run(cmd)
     LOG.debug(stdout)
 
@@ -99,14 +103,16 @@ def run(test_config):
         LOG.info("Create Dashboard data")
         DashBoard.posca_stress_ping(test_config["dashboard"])
 
-    LOG.info("yardstick envrionment prepare!")
+    LOG.info("bottlenecks envrionment prepare!")
     env_pre(con_dic)
+    LOG.info("yardstick envrionment prepare done!")
 
     for value in test_num:
         result = []
         out_num = 0
         num = int(value)
         pool = multiprocessing.Pool(processes=num)
+        LOG.info("begin to run %s thread" % num)
 
         starttime = datetime.datetime.now()
         for i in range(0, int(num)):
diff --git a/utils/env_prepare/quota_prepare.py b/utils/env_prepare/quota_prepare.py
new file mode 100644 (file)
index 0000000..e52a3e3
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+
+
+import os
+import commands
+import utils.logger as log
+import utils.infra_setup.heat.manager as client_manager
+
+LOG = log.Logger(__name__).getLogger()
+
+neutron_quota = {"subnet": -1,
+                 "network": -1,
+                 "floatingip": -1,
+                 "subnetpool": -1,
+                 "router": -1,
+                 "port": -1}
+
+nova_quota = {"ram": -1,
+              "cores": -1,
+              "instances": -1,
+              "key_pairs": -1,
+              "fixed_ips": -1,
+              "floating_ips": -1,
+              "server_groups": -1,
+              "injected_files": -1,
+              "metadata_items": -1,
+              "security_groups": -1,
+              "security_group_rules": -1,
+              "server_group_members": -1,
+              "injected_file_content_bytes": -1,
+              "injected_file_path_bytes": -1}
+
+
+def quota_env_prepare():
+    tenant_name = os.getenv("OS_TENANT_NAME")
+    cmd = ("openstack project list | grep " +
+           tenant_name +
+           " | awk '{print $2}'")
+
+    result = commands.getstatusoutput(cmd)
+    if result[0] == 0:
+        LOG.info(result[1])
+    else:
+        LOG.error("can't get openstack project id")
+        return 1
+
+    openstack_id = result[1]
+
+    nova_client = client_manager._get_nova_client()
+    neutron_client = client_manager._get_neutron_client()
+
+    nova_q = nova_client.quotas.get(openstack_id).to_dict()
+    neutron_q = neutron_client.show_quota(openstack_id)
+    LOG.info(tenant_name + "tenant nova and neutron quota(previous) :")
+    LOG.info(nova_q)
+    LOG.info(neutron_q)
+
+    nova_client.quotas.update(openstack_id, **nova_quota)
+    neutron_client.update_quota(openstack_id,
+                                {'quota': neutron_quota})
+    LOG.info("Quota has been changed!")
+
+    nova_q = nova_client.quotas.get(openstack_id).to_dict()
+    neutron_q = neutron_client.show_quota(openstack_id)
+    LOG.info(tenant_name + "tenant nova and neutron quota(now) :")
+    LOG.info(nova_q)
+    LOG.info(neutron_q)
+    return 0
index 37b523d..3c706fa 100644 (file)
@@ -28,10 +28,10 @@ def _prepare_env_daemon():
 
     _source_file(rc_file)
 
-    _append_external_network(rc_file)
+    _append_external_network(rc_file)
 
     # update the external_network
-    _source_file(rc_file)
+    _source_file(rc_file)
 
 
 def _get_remote_rc_file(rc_file, installer_ip, installer_type):