Li-Aihua commented on a change in pull request #10436: [FLINK-14920] 
[flink-end-to-end-perf-tests] Set up environment to run performance e2e tests
URL: https://github.com/apache/flink/pull/10436#discussion_r355165876
 
 

 ##########
 File path: tools/jenkins/run_case.py
 ##########
 @@ -0,0 +1,151 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+# This file will be runned by jenkis to run the e2e perf test
+# Params:
+# am_seserver_dddress: master machines's ip  of standalone environment
+# scenario_file: the file which contains test scenarios
+# flink_home: the path of flink
+# inter_nums:the num of every scenario's running, default value is 10
+# wait_minute: interval time of two elections of qps,default value is 10s
+#
+
+
+import sys
+import time
+
+if sys.version_info < (3, 5):
+    print("Python versions prior to 3.5 are not supported.")
+    sys.exit(-1)
+
+from logger import logger
+from utils import run_command
+from restapi_common import get_avg_qps_by_restful_interface
+
+
+def start_server(flink_home):
+    cmd = "bash %s/bin/start-cluster.sh" % flink_home
+    status, output = run_command(cmd)
+    if status and output.find("Exception") < 0:
+        return True
+    else:
+        return False
+
+
+def end_server(flink_home):
+    cmd = "bash %s/bin/stop_yarn.sh" % flink_home
+    status, output = run_command(cmd)
+    if status and output.find("Exception") < 0:
+        return True
+    else:
+        return False
+
+
+def get_scenarios(scenario_file_name, test_jar):
+    """
+    parser file which contains serval scenarios,it's content likes this:
+    classPath       scenarioName      jobparam1     jobparams2
+    org.apache.Test testScenario1     aaa           bbb
+    ……
+    :param scenario_file_name: scenario's file
+    :param test_jar:
+    :return: list of scenarios
+    """
+    params_name = []
+    scenarios = []
+    scenario_names = []
+    linenum = 0
+    with open(scenario_file_name) as file:
+        data = file.readline()
+        if not (data.startswith("#") or data == ""):
+            linenum = linenum + 1
+            cmd = ""
+            scenario_name = ""
+            if linenum == 1:
+                params_name = data.split(" ")
+                for index in range(0, len(params_name)):
+                    params_name[index] = params_name[index]
+                if not "testClassPath" in params_name:
+                    return 1, []
+            else:
+                params_value = data.split(" ")
+                for index in range(0, len(params_name)):
+                    param = params_name[index]
+                    if param == "testClassPath":
+                        cmd = "-c %s %s %s" % (params_value[index], test_jar,  
cmd)
+                    else:
+                        if param == "":
+                            cmd = "--%s %s" % (param, params_value[index])
+                        else:
+                            cmd = "%s --%s %s" % (cmd, param, 
params_value[index])
+                scenario_name = "%s_%s" % (scenario_name, param)
+            scenario_names.append(scenario_name[1:])
+            scenarios.append(cmd)
+    return 0, scenarios, scenario_names
+
+
+def get_avg(values):
+    if len(values) == 0:
+        return 0.0
+    else:
+        return sum(values) * 1.0 / len(values)
+
+
+def run_cases(scenario_file_name, flink_home, am_seserver_dddress, 
inter_nums=10, wait_minute=10):
+    status, scenarios, scenario_names = get_scenarios(scenario_file_name)
+    for scenario_index in range(0, len(scenarios)):
+        scenario = scenarios.get(scenario_index)
+        scenario_name = scenario_names[scenario_index]
+        total_qps = []
+        status = start_server(flink_home)
 
 Review comment:
   yes, it's ok to reuse cluster, i updated it 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to