aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/opnfv_yardstick_tc002.json
blob: 4a9b787645999a8feb7b84619bf7ccbe4e9a2ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
{
  "__inputs": [
    {
      "name": "DS_YARDSTICK",
      "label": "yardstick",
      "description": "",
      "type": "datasource",
      "pluginId": "influxdb",
      "pluginName": "InfluxDB"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "4.4.3"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "influxdb",
      "name": "InfluxDB",
      "version": "1.0.0"
    }
  ],
  "annotations": {
    "list": []
  },
  "description": "",
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "hideControls": false,
  "id": null,
  "links": [],
  "refresh": false,
  "rows": [
    {
      "collapse": false,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "dashLength": 10,
          "dashes": false,
          "datasource": "yardstick",
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {},
          "id": 1,
          "legend": {
            "alignAsTable": false,
            "avg": false,
            "current": false,
            "max": true,
            "min": true,
            "rightSide": false,
            "show": true,
            "total": false,
            "values": true
          },
          "lines": false,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": true,
          "renderer": "flot",
          "seriesOverrides": [],
          "spaceLength": 10,
          "span": 12,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "RTT",
              "dsType": "influxdb",
              "groupBy": [],
              "measurement": "opnfv_yardstick_tc002",
              "orderByTime": "ASC",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "rtt.ares"
                    ],
                    "type": "field"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "thresholds": [
            {
              "colorMode": "custom",
              "fill": true,
              "fillColor": "rgba(234, 112, 112, 0.22)",
              "op": "gt",
              "value": 10
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Ping - RTT (Round-trip time)",
          "tooltip": {
            "msResolution": true,
            "shared": true,
            "sort": 0,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }
          ]
        }
      ],
      "repeat": null,
      "repeatIteration": null,
      "repeatRowId": null,
      "showTitle": false,
      "title": "Row",
      "titleSize": "h6"
    }
  ],
  "schemaVersion": 14,
  "style": "dark",
  "tags": [
    "Network"
  ],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now/d",
    "to": "now/d"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "browser",
  "title": "opnfv_yardstick_tc002",
  "version": 8
}
class="s2">"blueprint") CFY_INPUTS = functest_yaml.get("vIMS").get("cloudify").get("inputs") CFY_INPUTS_PATH = functest_yaml.get("vIMS").get("cloudify").get("inputs_path") CW_BLUEPRINT = functest_yaml.get("vIMS").get("clearwater").get("blueprint") CW_DEPLOYMENT_NAME = functest_yaml.get("vIMS").get("clearwater").get("deployment-name") CW_INPUTS = functest_yaml.get("vIMS").get("clearwater").get("inputs") CW_DOMAIN_NAME = functest_yaml.get("vIMS").get("clearwater").get("inputs").get("public_domain") CFY_DEPLOYMENT_DURATION = 0 CW_DEPLOYMENT_DURATION = 0 def pMsg(value): """pretty printing""" pp.pprint(value) def download_and_add_image_on_glance(glance, image_name, image_url): dest_path = VIMS_DATA_DIR + "tmp/" if not os.path.exists(dest_path): os.makedirs(dest_path) file_name = image_url.rsplit('/')[-1] if not functest_utils.download_url(image_url, dest_path): logger.error("Failed to download image %s" %file_name) return False image = functest_utils.create_glance_image(glance, image_name, dest_path + file_name) if not image: logger.error("Failed to upload image on glance") return False return image def download_blueprints(blueprint_url, branch, dest_path): if os.path.exists(dest_path): shutil.rmtree(dest_path) try: Repo.clone_from(blueprint_url, dest_path, branch=branch) return True except: return False def initialize_deployments(): if not os.path.exists(VIMS_DATA_DIR): os.makedirs(VIMS_DATA_DIR) ks_creds = functest_utils.get_credentials("keystone") nv_creds = functest_utils.get_credentials("nova") nt_creds = functest_utils.get_credentials("neutron") logger.info("Prepare OpenStack plateform (create tenant and user)") keystone = ksclient.Client(**ks_creds) user_id = functest_utils.get_user_id(keystone, ks_creds['username']) if user_id == '': logger.error("Error : Failed to get id of %s user" %ks_creds['username']) exit(-1) tenant_id = functest_utils.create_tenant(keystone, TENANT_NAME, TENANT_DESCRIPTION) if tenant_id == '': logger.error("Error : Failed to create %s tenant" %TENANT_NAME) exit(-1) role_name = "admin" role_id = functest_utils.get_role_id(keystone, role_name) if role_id == '': logger.error("Error : Failed to get id for %s role" %role_name) if not functest_utils.add_role_user(keystone, user_id, role_id, tenant_id): logger.error("Error : Failed to add %s on tenant" %ks_creds['username']) user_id = functest_utils.create_user(keystone, TENANT_NAME, TENANT_NAME, None, tenant_id) if user_id == '': logger.error("Error : Failed to create %s user" %TENANT_NAME) logger.info("Update OpenStack creds informations") ks_creds.update({ "username": TENANT_NAME, "password": TENANT_NAME, "tenant_name": TENANT_NAME, }) nt_creds.update({ "tenant_name": TENANT_NAME, }) nv_creds.update({ "project_id": TENANT_NAME, }) logger.info("Upload ubuntu image if it doesn't exist") glance_endpoint = keystone.service_catalog.url_for(service_type='image', endpoint_type='publicURL') glance = glclient.Client(1, glance_endpoint, token=keystone.auth_token) image_id = functest_utils.get_image_id(glance, BASE_IMAGE_NAME) if image_id == '': logger.info("""%s image doesn't exist on glance repository. Try downloading this image and upload on glance !""" %BASE_IMAGE_NAME) image_id = download_and_add_image_on_glance(glance, BASE_IMAGE_NAME, BASE_IMAGE_URL) if image_id == '': logger.error("Error : Failed to find or upload required OS image for this deployment" %flavor_name) exit(-1) logger.info("Collect flavor id for cloudify and clearwater VMs") nova = nvclient.Client("2", **nv_creds) flavor_name = "m1.small" flavor_id = functest_utils.get_flavor_id(nova, flavor_name) if flavor_id == '': logger.error("Failed to find %s flavor. Try with ram range requirement !" %flavor_name) flavor_id = get_flavor_id_by_ram_range(nova, 1792, 2048) if flavor_id == '': logger.error("Failed to find required flavor for this deployment" %flavor_name) exit(-1) logger.info("Update security group quota for this tenant") neutron = ntclient.Client(**nt_creds) if not functest_utils.update_sg_quota(neutron, tenant_id, 50, 100): logger.error("Failed to update security group quota for tenant %s" %TENANT_NAME) exit(-1) ext_net = functest_utils.get_external_net(neutron) if not ext_net: logger.error("Failed to get external network") exit(-1) logger.info("Update inputs informations") CFY_INPUTS['image_id'] = image_id CFY_INPUTS['flavor_id'] = flavor_id CFY_INPUTS['external_network_name'] = ext_net CW_INPUTS['image_id'] = image_id CW_INPUTS['flavor_id'] = flavor_id CW_INPUTS['external_network_name'] = ext_net CFY_INPUTS['keystone_username'] = ks_creds['username'] CFY_INPUTS['keystone_password'] = ks_creds['password'] CFY_INPUTS['keystone_url'] = ks_creds['auth_url'] CFY_INPUTS['keystone_tenant_name'] = ks_creds['tenant_name'] logger.info("Prepare virtualenv for cloudify-cli") cmd = "chmod +x " + VIMS_DIR + "create_venv.sh" functest_utils.execute_command(cmd,logger) cmd = VIMS_DIR + "create_venv.sh " + VIMS_DATA_DIR functest_utils.execute_command(cmd,logger) def cleanup_deployments(): ks_creds = functest_utils.get_credentials("keystone") keystone = ksclient.Client(**ks_creds) logger.info("Removing %s tenant .." %CFY_INPUTS['keystone_tenant_name']) tenant_id = functest_utils.get_tenant_id(keystone, CFY_INPUTS['keystone_tenant_name']) if tenant_id == '': logger.error("Error : Failed to get id of %s tenant" %CFY_INPUTS['keystone_tenant_name']) else: if not functest_utils.delete_tenant(keystone, tenant_id): logger.error("Error : Failed to remove %s tenant" %CFY_INPUTS['keystone_tenant_name']) logger.info("Removing %s user .." %CFY_INPUTS['keystone_username']) user_id = functest_utils.get_user_id(keystone, CFY_INPUTS['keystone_username']) if user_id == '': logger.error("Error : Failed to get id of %s user" %CFY_INPUTS['keystone_username']) else: if not functest_utils.delete_user(keystone, user_id): logger.error("Error : Failed to remove %s user" %CFY_INPUTS['keystone_username']) def deploy_cloudify_manager(): logger.info("Downloading the cloudify manager server blueprint") download_result = download_blueprints(CFY_MANAGER_BLUEPRINT['url'], CFY_MANAGER_BLUEPRINT['branch'], VIMS_DATA_DIR + 'cloudify-manager-blueprint/') if not download_result: logger.error("Failed to download manager blueprint") exit(-1) logger.info("Writing the inputs file") with open( VIMS_DATA_DIR + 'cloudify-manager-blueprint/' + CFY_INPUTS_PATH, "w") as f: f.write(yaml.dump(CFY_INPUTS, default_style='"') ) f.close() start_time_ts = time.time() end_time_ts = start_time_ts logger.info("Cloudify deployment Start Time:'%s'" % ( datetime.datetime.fromtimestamp(start_time_ts).strftime( '%Y-%m-%d %H:%M:%S'))) logger.info("Launching the cloudify-manager deployment") script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " script += "cd " + VIMS_DATA_DIR + "; " script += "cfy init -r; " script += "cd cloudify-manager-blueprint/openstack; " script += "cfy local create-requirements -o requirements.txt -p openstack-manager-blueprint.yaml; " script += "pip install -r requirements.txt; " script += "cfy bootstrap --install-plugins -p openstack-manager-blueprint.yaml -i inputs.yaml; " cmd = "/bin/bash -c '" + script + "'" functest_utils.execute_command(cmd, logger) logger.info("Cloudify-manager server is UP !") global CFY_DEPLOYMENT_DURATION end_time_ts = time.time() CFY_DEPLOYMENT_DURATION = round(end_time_ts - start_time_ts, 1) logger.info("Cloudify deployment duration:'%s'" %CFY_DEPLOYMENT_DURATION) def undeploy_cloudify_manager(): logger.info("Launching the cloudify-manager undeployment") script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " script += "cd " + VIMS_DATA_DIR + "; " script += "cfy teardown -f; " cmd = "/bin/bash -c '" + script + "'" functest_utils.execute_command(cmd, logger) logger.info("Cloudify-manager server has been successfully removed!") def deploy_clearwater(): logger.info("Downloading the {0} blueprint".format(CW_BLUEPRINT['file_name'])) download_result = download_blueprints(CW_BLUEPRINT['url'], CW_BLUEPRINT['branch'], VIMS_DATA_DIR + CW_BLUEPRINT['destination_folder']) if not download_result: logger.error("Failed to download blueprint {0}".format(CW_BLUEPRINT['file_name'])) exit(-1) logger.info("Writing the inputs file") with open(VIMS_DATA_DIR + CW_BLUEPRINT['destination_folder'] + "/inputs.yaml", "w") as f: f.write(yaml.dump(CW_INPUTS, default_style='"') ) f.close() time.sleep(30) start_time_ts = time.time() end_time_ts = start_time_ts logger.info("vIMS VNF deployment Start Time:'%s'" % ( datetime.datetime.fromtimestamp(start_time_ts).strftime( '%Y-%m-%d %H:%M:%S'))) logger.info("Launching the {0} deployment".format(CW_BLUEPRINT['name'])) script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " script += "cd " + VIMS_DATA_DIR + CW_BLUEPRINT['destination_folder'] + "; " script += "cfy blueprints upload -b " + CW_BLUEPRINT['name'] + " -p openstack-blueprint.yaml; " script += "cfy deployments create -b " + CW_BLUEPRINT['name'] + " -d " + CW_DEPLOYMENT_NAME + " --inputs inputs.yaml; " script += "cfy executions start -w install -d " + CW_DEPLOYMENT_NAME + " --timeout 1800; " cmd = "/bin/bash -c '" + script + "'" functest_utils.execute_command(cmd, logger) logger.info("Clearwater vIMS is UP !") global CW_DEPLOYMENT_DURATION end_time_ts = time.time() CW_DEPLOYMENT_DURATION = round(end_time_ts - start_time_ts, 1) logger.info("vIMS VNF deployment duration:'%s'" %CW_DEPLOYMENT_DURATION) def undeploy_clearwater(): logger.info("Launching the {0} undeployment".format(CW_BLUEPRINT['name'])) script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " script += "cd " + VIMS_DATA_DIR + "; " script += "cfy executions start -w uninstall -d " + CW_DEPLOYMENT_NAME + " --timeout 1800 ; " script += "cfy deployments delete -d " + CW_DEPLOYMENT_NAME + "; " cmd = "/bin/bash -c '" + script + "'" functest_utils.execute_command(cmd, logger) def test_clearwater(): time.sleep(180) script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " script += "cd " + VIMS_DATA_DIR + "; " script += "cfy deployments outputs -d " + CW_DEPLOYMENT_NAME + " | grep Value: | sed \"s/ *Value: //g\";" cmd = "/bin/bash -c '" + script + "'" try: logger.debug("Trying to get clearwater nameserver IP ... ") dns_ip = os.popen(cmd).read() dns_ip = dns_ip.splitlines()[0] except: logger.error("Unable to retrieve the IP of the DNS server !") start_time_ts = time.time() end_time_ts = start_time_ts logger.info("vIMS functional test Start Time:'%s'" % ( datetime.datetime.fromtimestamp(start_time_ts).strftime( '%Y-%m-%d %H:%M:%S'))) if dns_ip != "": script = 'echo -e "nameserver ' + dns_ip + '\nnameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf; ' script += 'source /etc/profile.d/rvm.sh; ' script += 'cd ' + VIMS_TEST_DIR + '; ' script += 'rake test[' + CW_INPUTS["public_domain"] + '] SIGNUP_CODE="secret"' cmd = "/bin/bash -c '" + script + "'" output_file = "output.txt" f = open(output_file, 'w+') p = subprocess.call(cmd, shell=True, stdout=f, stderr=subprocess.STDOUT) f.close() end_time_ts = time.time() duration = round(end_time_ts - start_time_ts, 1) logger.info("vIMS functional test duration:'%s'" %duration) f = open(output_file, 'r') result = f.read() if result != "" and logger: logger.debug(result) vims_test_result="" try: logger.debug("Trying to load test results") with open(VIMS_TEST_DIR + "temp.json") as f: vims_test_result = json.load(f) f.close() except: logger.error("Unable to retrieve test results") if vims_test_result != "" & args.report: logger.debug("Push result into DB") logger.debug("Pushing results to DB....") git_version = functest_utils.get_git_branch(args.repo_path) functest_utils.push_results_to_db(db_url=TEST_DB, case_name="vIMS", logger=logger, pod_name="opnfv-jump-2", git_version=git_version, payload={'orchestrator':{'duration': CFY_DEPLOYMENT_DURATION, 'result': ""}, 'vIMS': {'duration': CW_DEPLOYMENT_DURATION, 'result': ""}, 'sig_test': {'duration': duration, 'result': vims_test_result}}) try: os.remove(VIMS_TEST_DIR + "temp.json") except: logger.error("Deleting file failed") def main(): initialize_deployments() deploy_cloudify_manager() deploy_clearwater() test_clearwater() undeploy_clearwater() undeploy_cloudify_manager() cleanup_deployments() if __name__ == '__main__': main()