diff options
author | earrage <eddie.arrage@huawei.com> | 2018-11-02 14:40:55 -0700 |
---|---|---|
committer | Eddie Arrage <eddie.arrage@huawei.com> | 2018-11-02 21:52:50 +0000 |
commit | d9bbeea6a6a0a37f60580a28c093aed96c033c26 (patch) | |
tree | 408599c28c826262b9aa623ef684a154044d6f85 | |
parent | 76327cfcbef2079ea2ff0775b3b55286b28182ee (diff) |
Add minor enhancements to jmeter configuration
- Add user-agent field to jmeter config yaml and jmeter jmx
template that can be configured per URL in testplan
- Add duration time that can be used in combination with
ramp time. Duration is the total time of the test while
ramp time governs how much time is allotted to establish
all configured requests/connections
- Explicitly define clover-jmeter-master service name with
default namespace for clover-controller in clover-system
namespace to reach
- Add missing request_counts.html file
Change-Id: I5e2d388db0b73ea6c28482c94c33cc2a01f1b52e
Signed-off-by: earrage <eddie.arrage@huawei.com>
7 files changed, 75 insertions, 17 deletions
diff --git a/clover/cloverctl/src/cloverctl/yaml/jmeter_testplan.yaml b/clover/cloverctl/src/cloverctl/yaml/jmeter_testplan.yaml index 140e70f..92d53ea 100644 --- a/clover/cloverctl/src/cloverctl/yaml/jmeter_testplan.yaml +++ b/clover/cloverctl/src/cloverctl/yaml/jmeter_testplan.yaml @@ -1,11 +1,14 @@ load_spec: - num_threads: 1 - loops: 1 + num_threads: 5 + loops: 2 ramp_time: 60 + duration: 80 url_list: - name: url1 url: http://proxy-access-control.default:9180 method: GET + user-agent: chrome - name: url2 url: http://proxy-access-control.default:9180 method: GET + user-agent: safari diff --git a/clover/controller/control/api/jmeter.py b/clover/controller/control/api/jmeter.py index 09625f5..3e8b86a 100644 --- a/clover/controller/control/api/jmeter.py +++ b/clover/controller/control/api/jmeter.py @@ -16,29 +16,34 @@ import logging jmeter = Blueprint('jmeter', __name__) grpc_port = '50054' -pod_name = 'clover-jmeter-master' +pod_name = 'clover-jmeter-master.default' jmeter_grpc = pod_name + ':' + grpc_port channel = grpc.insecure_channel(jmeter_grpc) stub = jmeter_pb2_grpc.ControllerStub(channel) @jmeter.route("/jmeter/gen", methods=['GET', 'POST']) +@jmeter.route("/jmeter/create", methods=['GET', 'POST']) def gentest(): try: p = request.json u_list = [] u_names = [] u_methods = [] + u_agents = [] try: for u in p['url_list']: u_list.append(u['url']) u_names.append(u['name']) u_methods.append(u['method']) + u_agents.append(u['user-agent']) url_list = pickle.dumps(u_list) url_names = pickle.dumps(u_names) url_methods = pickle.dumps(u_methods) + url_agents = pickle.dumps(u_agents) num_threads = p['load_spec']['num_threads'] ramp_time = p['load_spec']['ramp_time'] + duration = p['load_spec']['duration'] loops = p['load_spec']['loops'] except (KeyError, ValueError) as e: logging.debug(e) @@ -46,7 +51,7 @@ def gentest(): response = stub.GenTest(jmeter_pb2.ConfigJmeter( url_list=url_list, url_names=url_names, url_methods=url_methods, num_threads=str(num_threads), ramp_time=str(ramp_time), - loops=str(loops))) + url_agents=url_agents, duration=str(duration), loops=str(loops))) except Exception as e: logging.debug(e) if e.__class__.__name__ == "_Rendezvous": diff --git a/clover/controller/control/templates/request_counts.html b/clover/controller/control/templates/request_counts.html new file mode 100644 index 0000000..ecf458a --- /dev/null +++ b/clover/controller/control/templates/request_counts.html @@ -0,0 +1,21 @@ +<div class="large-4 medium-3 cell clover-portlet small-offset-2"> + <h5>Per Service Counts</h5> + <div class="span_node_id_all"> + </div> +</div> +<div class="large-4 medium-3 cell clover-portlet"> + <h5>Per URL Counts (all services)</h5> + <div class="span_urls_all"> + </div> +</div> + +<div class="large-4 medium-3 cell clover-portlet small-offset-2"> + <h5>Per URL / HTTP Status Codes (all services)</h5> + <div class="status_codes_all"> + </div> +</div> +<div class="large-4 medium-3 cell clover-portlet"> + <h5>User-Agent Percentage</h5> + <div class="span_user_agents_all" id="span_user_agents_all"> + </div> +</div> diff --git a/clover/tools/jmeter/jmeter-master/grpc/jmeter.proto b/clover/tools/jmeter/jmeter-master/grpc/jmeter.proto index 7213faa..f65ed6c 100644 --- a/clover/tools/jmeter/jmeter-master/grpc/jmeter.proto +++ b/clover/tools/jmeter/jmeter-master/grpc/jmeter.proto @@ -29,8 +29,10 @@ message ConfigJmeter { string url_names = 3; string url_protocols = 4; string url_methods = 5; - string loops = 6; - string ramp_time = 7; + string url_agents = 6; + string loops = 7; + string ramp_time = 8; + string duration = 9; } message JmeterReply { diff --git a/clover/tools/jmeter/jmeter-master/grpc/jmeter_pb2.py b/clover/tools/jmeter/jmeter-master/grpc/jmeter_pb2.py index e4a75fd..7a2d62c 100644 --- a/clover/tools/jmeter/jmeter-master/grpc/jmeter_pb2.py +++ b/clover/tools/jmeter/jmeter-master/grpc/jmeter_pb2.py @@ -19,7 +19,7 @@ DESCRIPTOR = _descriptor.FileDescriptor( name='jmeter.proto', package='jmeter', syntax='proto3', - serialized_pb=_b('\n\x0cjmeter.proto\x12\x06jmeter\"F\n\nTestParams\x12\x12\n\nnum_slaves\x18\x01 \x01(\t\x12\x11\n\ttest_plan\x18\x02 \x01(\t\x12\x11\n\tslave_ips\x18\x03 \x01(\t\"\x96\x01\n\x0c\x43onfigJmeter\x12\x10\n\x08url_list\x18\x01 \x01(\t\x12\x13\n\x0bnum_threads\x18\x02 \x01(\t\x12\x11\n\turl_names\x18\x03 \x01(\t\x12\x15\n\rurl_protocols\x18\x04 \x01(\t\x12\x13\n\x0burl_methods\x18\x05 \x01(\t\x12\r\n\x05loops\x18\x06 \x01(\t\x12\x11\n\tramp_time\x18\x07 \x01(\t\"\x1e\n\x0bJmeterReply\x12\x0f\n\x07message\x18\x01 \x01(\t\",\n\x08JResults\x12\x10\n\x08r_format\x18\x01 \x01(\t\x12\x0e\n\x06r_file\x18\x02 \x01(\t2\xb3\x01\n\nController\x12\x36\n\x07GenTest\x12\x14.jmeter.ConfigJmeter\x1a\x13.jmeter.JmeterReply\"\x00\x12\x36\n\tStartTest\x12\x12.jmeter.TestParams\x1a\x13.jmeter.JmeterReply\"\x00\x12\x35\n\nGetResults\x12\x10.jmeter.JResults\x1a\x13.jmeter.JmeterReply\"\x00\x62\x06proto3') + serialized_pb=_b('\n\x0cjmeter.proto\x12\x06jmeter\"F\n\nTestParams\x12\x12\n\nnum_slaves\x18\x01 \x01(\t\x12\x11\n\ttest_plan\x18\x02 \x01(\t\x12\x11\n\tslave_ips\x18\x03 \x01(\t\"\xbc\x01\n\x0c\x43onfigJmeter\x12\x10\n\x08url_list\x18\x01 \x01(\t\x12\x13\n\x0bnum_threads\x18\x02 \x01(\t\x12\x11\n\turl_names\x18\x03 \x01(\t\x12\x15\n\rurl_protocols\x18\x04 \x01(\t\x12\x13\n\x0burl_methods\x18\x05 \x01(\t\x12\x12\n\nurl_agents\x18\x06 \x01(\t\x12\r\n\x05loops\x18\x07 \x01(\t\x12\x11\n\tramp_time\x18\x08 \x01(\t\x12\x10\n\x08\x64uration\x18\t \x01(\t\"\x1e\n\x0bJmeterReply\x12\x0f\n\x07message\x18\x01 \x01(\t\",\n\x08JResults\x12\x10\n\x08r_format\x18\x01 \x01(\t\x12\x0e\n\x06r_file\x18\x02 \x01(\t2\xb3\x01\n\nController\x12\x36\n\x07GenTest\x12\x14.jmeter.ConfigJmeter\x1a\x13.jmeter.JmeterReply\"\x00\x12\x36\n\tStartTest\x12\x12.jmeter.TestParams\x1a\x13.jmeter.JmeterReply\"\x00\x12\x35\n\nGetResults\x12\x10.jmeter.JResults\x1a\x13.jmeter.JmeterReply\"\x00\x62\x06proto3') ) @@ -113,19 +113,33 @@ _CONFIGJMETER = _descriptor.Descriptor( is_extension=False, extension_scope=None, options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='loops', full_name='jmeter.ConfigJmeter.loops', index=5, + name='url_agents', full_name='jmeter.ConfigJmeter.url_agents', index=5, number=6, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='ramp_time', full_name='jmeter.ConfigJmeter.ramp_time', index=6, + name='loops', full_name='jmeter.ConfigJmeter.loops', index=6, number=7, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='ramp_time', full_name='jmeter.ConfigJmeter.ramp_time', index=7, + number=8, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='duration', full_name='jmeter.ConfigJmeter.duration', index=8, + number=9, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -139,7 +153,7 @@ _CONFIGJMETER = _descriptor.Descriptor( oneofs=[ ], serialized_start=97, - serialized_end=247, + serialized_end=285, ) @@ -169,8 +183,8 @@ _JMETERREPLY = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=249, - serialized_end=279, + serialized_start=287, + serialized_end=317, ) @@ -207,8 +221,8 @@ _JRESULTS = _descriptor.Descriptor( extension_ranges=[], oneofs=[ ], - serialized_start=281, - serialized_end=325, + serialized_start=319, + serialized_end=363, ) DESCRIPTOR.message_types_by_name['TestParams'] = _TESTPARAMS @@ -253,8 +267,8 @@ _CONTROLLER = _descriptor.ServiceDescriptor( file=DESCRIPTOR, index=0, options=None, - serialized_start=328, - serialized_end=507, + serialized_start=366, + serialized_end=545, methods=[ _descriptor.MethodDescriptor( name='GenTest', diff --git a/clover/tools/jmeter/jmeter-master/grpc/jmeter_server.py b/clover/tools/jmeter/jmeter-master/grpc/jmeter_server.py index cef180c..9f9e561 100644 --- a/clover/tools/jmeter/jmeter-master/grpc/jmeter_server.py +++ b/clover/tools/jmeter/jmeter-master/grpc/jmeter_server.py @@ -37,6 +37,7 @@ class Controller(jmeter_pb2_grpc.ControllerServicer): template_file = 'tests/jmx.template' unames = pickle.loads(r.url_names) umethods = pickle.loads(r.url_methods) + uagents = pickle.loads(r.url_agents) ulist = [] for url in pickle.loads(r.url_list): u = urlparse(url) @@ -58,7 +59,9 @@ class Controller(jmeter_pb2_grpc.ControllerServicer): num_threads=r.num_threads, url_names=unames, url_methods=umethods, + url_agents=uagents, ramp_time=r.ramp_time, + duration=r.duration, loops=r.loops, url_list=ulist ) diff --git a/clover/tools/jmeter/jmeter-master/tests/jmx.template b/clover/tools/jmeter/jmeter-master/tests/jmx.template index 1a6fa95..ad3414d 100644 --- a/clover/tools/jmeter/jmeter-master/tests/jmx.template +++ b/clover/tools/jmeter/jmeter-master/tests/jmx.template @@ -23,7 +23,7 @@ <longProp name="ThreadGroup.start_time">1385457190000</longProp> <longProp name="ThreadGroup.end_time">1385457190000</longProp> <boolProp name="ThreadGroup.scheduler">true</boolProp> - <stringProp name="ThreadGroup.duration">60</stringProp> + <stringProp name="ThreadGroup.duration">{{ duration }}</stringProp> <stringProp name="ThreadGroup.delay"/> <boolProp name="ThreadGroup.delayedStart">true</boolProp> </ThreadGroup> @@ -49,7 +49,17 @@ <stringProp name="HTTPSampler.embedded_url_re"/> <stringProp name="HTTPSampler.implementation"/> </HTTPSampler> + <hashTree> + <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true"> + <collectionProp name="HeaderManager.headers"> + <elementProp name="" elementType="Header"> + <stringProp name="Header.name">User-Agent</stringProp> + <stringProp name="Header.value">{{ url_agents[loop.index0] }}</stringProp> + </elementProp> + </collectionProp> + </HeaderManager> <hashTree/> + </hashTree> {%- endfor %} |