X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Fhelper-scripts%2Frapid%2Frapid_corestatstest.py;h=e6a7f517808f643f9a856f731a04cd07bff9121e;hb=894f62216ca3c97ef0c1c09b9475459b9324b1bb;hp=c55c67f15220bee47c4cf5e067cab662dbbe6b02;hpb=4d932aced6931d756e07dbce6ab7cf04799ba5f4;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py index c55c67f1..e6a7f517 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py @@ -1,7 +1,7 @@ #!/usr/bin/python ## -## Copyright (c) 2010-2020 Intel Corporation +## Copyright (c) 2020 Intel Corporation ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import sys import time +import requests from rapid_log import RapidLog from rapid_test import RapidTest @@ -26,22 +27,19 @@ class CoreStatsTest(RapidTest): """ Class to manage the corestatstesting """ - def __init__(self, runtime, pushgateway, environment_file, machines): - self.runtime = runtime - self.pushgateway = pushgateway - self.environment_file = environment_file - self.machines = machines + def __init__(self, test_param, runtime, testname, environment_file, + machines): + super().__init__(test_param, runtime, testname, environment_file) + self.machines = machines def run(self): - # fieldnames = ['PROXID','Time','Received','Sent','NonDPReceived','NonDPSent','Delta','NonDPDelta','Dropped'] - # writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames) - # writer.writeheader() + result_details = {'Details': 'Nothing'} RapidLog.info("+------------------------------------------------------------------------------------------------------------------+") RapidLog.info("| Measuring core statistics on 1 or more PROX instances |") RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+") RapidLog.info("| PROX ID | Time | RX | TX | non DP RX | non DP TX | TX - RX | nonDP TX-RX| DROP TOT |") RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+") - duration = self.runtime + duration = self.test['runtime'] tot_drop = [] old_rx = []; old_non_dp_rx = []; old_tx = []; old_non_dp_tx = []; old_drop = []; old_tx_fail = []; old_tsc = [] new_rx = []; new_non_dp_rx = []; new_tx = []; new_non_dp_tx = []; new_drop = []; new_tx_fail = []; new_tsc = [] @@ -74,18 +72,19 @@ class CoreStatsTest(RapidTest): old_tsc[i] = new_tsc[i] tot_drop[i] = tot_drop[i] + tx - rx RapidLog.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(non_dp_rx)+' | '+'{:>10.0f}'.format(non_dp_tx)+' | ' + '{:>10.0f}'.format(tx-rx) + ' | '+ '{:>10.0f}'.format(non_dp_tx-non_dp_rx) + ' | '+'{:>10.0f}'.format(tot_drop[i]) +' |') - # writer.writerow({'PROXID':i,'Time':duration,'Received':rx,'Sent':tx,'NonDPReceived':non_dp_rx,'NonDPSent':non_dp_tx,'Delta':tx-rx,'NonDPDelta':non_dp_tx-non_dp_rx,'Dropped':tot_drop[i]}) - if self.pushgateway: - URL = self.pushgateway+ '/metrics/job/' + TestName + '/instance/' + self.environment_file + str(i) - DATA = 'PROXID {}\nTime {}\n Received {}\nSent {}\nNonDPReceived {}\nNonDPSent {}\nDelta {}\nNonDPDelta {}\nDropped {}\n'.format(i,duration,rx,tx,non_dp_rx,non_dp_tx,tx-rx,non_dp_tx-non_dp_rx,tot_drop[i]) - HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'} - response = requests.post(url=URL, data=DATA,headers=HEADERS) - if (response.status_code != 202) and (response.status_code != 200): - RapidLog.info('Cannot send metrics to {}'.format(URL)) - RapidLog.info(DATA) + result_details = {'test': self.test['test'], + 'environment_file': self.test['environment_file'], + 'PROXID': i, + 'StepSize': duration, + 'Received': rx, + 'Sent': tx, + 'NonDPReceived': non_dp_rx, + 'NonDPSent': non_dp_tx, + 'Dropped': tot_drop[i]} + result_details = self.post_data(result_details) if machines_to_go == 0: duration = duration - 1 machines_to_go = len (self.machines) RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+") - return (True) + return (True, result_details)