__init__.py 2.36 KB
Newer Older
1 2 3
import os.path
import json

4 5 6
PERSON_KEY = "person_per_hour"
ORDER_KEY = "sale_order_per_hour"

7 8 9
class ERP5_scalability():

  def getTestList(self):
10
    return ['createPerson', 'createSaleOrder']
11 12

  def getTestPath(self):
13
    return 'example/'
14 15

  def getUsersFilePath(self):
16
    return 'example/scalabilityUsers'
17 18

  def getUserQuantity(self, test_number):
19
    return [20, 30, 40, 50, 60][test_number]
20 21 22

  # Test duration in seconds
  def getTestDuration(self, test_number):
23
    return 8*self.getUserQuantity(test_number)
24 25 26 27 28

  def getTestRepetition(self, test_number):
    return 3

  def getScalabilityTestUrl(self, instance_information_dict):
29 30
    frontend_address = instance_information_dict['frontend-url-list'][0]
    return "%s/erp5" % frontend_address
31 32

  def getScalabilityTestMetricUrl(self, instance_information_dict, **kw):
33 34 35 36 37
    frontend_address = instance_information_dict['frontend-url-list'][0]
    metrics_url = frontend_address.replace("https://",
                    "https://%s:%s@" % (instance_information_dict['user'],
                                        instance_information_dict['password']))
    return metrics_url + "/erp5/ERP5Site_getScalabilityTestMetric"
38 39

  def getScalabilityTestOutput(self, metric_list):
40 41 42 43
    """
    From the list of metrics taken during a test run, select the best metric
    for the test output by a specific criteria
    """
44 45 46 47
    if not metric_list: return None
    output_json = json.loads(metric_list[0])
    for metric in metric_list:
      metric_json = json.loads(metric)
48 49 50 51
      if metric_json[PERSON_KEY] > output_json[PERSON_KEY]:
        output_json[PERSON_KEY] = metric_json[PERSON_KEY]
      if metric_json[ORDER_KEY] > output_json[ORDER_KEY]:
        output_json[ORDER_KEY] = metric_json[ORDER_KEY]
52
    return "Person: %s doc/hour; SaleOrder: %s doc/hour;" % (
53
            str(output_json[PERSON_KEY]), str(output_json[ORDER_KEY]))
54 55

  def getBootstrapScalabilityTestUrl(self, instance_information_dict, count=0, **kw):
56 57 58 59 60
    frontend_address = instance_information_dict['frontend-url-list'][0]
    bootstrap_url = frontend_address.replace("https://",
                      "https://%s:%s@" % (instance_information_dict['user'],
                                          instance_information_dict['password']))
    bootstrap_url += "/erp5/ERP5Site_bootstrapScalabilityTest"
61 62
    bootstrap_url += "?user_quantity=%i" % self.getUserQuantity(count)
    return bootstrap_url