Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Blazemeter/taurus
Browse files Browse the repository at this point in the history
  • Loading branch information
undera committed May 27, 2019
2 parents 86bf760 + 0a238a1 commit fec770a
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 45 deletions.
2 changes: 1 addition & 1 deletion bzt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys
from abc import abstractmethod

VERSION = "1.13.5"
VERSION = "1.13.6"


class RCProvider(object):
Expand Down
5 changes: 4 additions & 1 deletion bzt/jmx/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ def modify(self, jmx):

concurrency_list = []
for group in groups:
concurrency_list.append(group.get_concurrency(raw=raw))
concurrency = group.get_concurrency(raw=raw)
if concurrency is None:
concurrency = 1
concurrency_list.append(concurrency)

if not raw: # divide numeric concurrency
self._divide_concurrency(concurrency_list)
Expand Down
1 change: 1 addition & 0 deletions bzt/modules/blazemeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"proxy": True,
"check-updates": True
},
"included-configs": True,
"cli": True,
"cli-aliases": True,
"install-id": True,
Expand Down
14 changes: 8 additions & 6 deletions bzt/modules/gatling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
import json
import codecs
import json
import os
import re
import time
Expand All @@ -28,10 +28,10 @@
from bzt.modules.aggregator import ConsolidatingAggregator, ResultsReader
from bzt.modules.console import WidgetProvider, ExecutorWidget
from bzt.requests_model import HTTPRequest
from bzt.six import string_types, numeric_types
from bzt.six import string_types, numeric_types, PY2
from bzt.utils import TclLibrary, EXE_SUFFIX, dehumanize_time, get_full_path, FileReader, RESOURCES_DIR, BetterDict
from bzt.utils import unzip, RequiredTool, JavaVM, shutdown_process, ensure_is_dict, is_windows
from bzt.utils import simple_body_dict, CALL_PROBLEMS
from bzt.utils import unzip, RequiredTool, JavaVM, shutdown_process, ensure_is_dict, is_windows


class GatlingScriptBuilder(object):
Expand Down Expand Up @@ -402,9 +402,11 @@ def _set_env(self):
prop = props[key]
val_tpl = "%s"

# extend properties support (contained separators/quotes/etc.) on lin/mac
if not is_windows() and isinstance(prop, string_types):
val_tpl = "%r"
if isinstance(prop, string_types):
if not is_windows(): # extend properties support (contained separators/quotes/etc.) on lin/mac
val_tpl = "%r"
if PY2:
prop = prop.encode("utf-8", 'ignore') # to convert from unicode into str

self.env.add_java_param({"JAVA_OPTS": ("-D%s=" + val_tpl) % (key, prop)})

Expand Down
14 changes: 5 additions & 9 deletions bzt/modules/jmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,20 +1465,16 @@ def run_and_check(self):
try:
out, err = self.call(cmd_line)
except CALL_PROBLEMS as exc:
self.log.debug("JMeter check failed: %s", exc)
msg = "JMeter check failed: %s" % exc
if os.path.exists(self.tool_path):
raise ToolError(msg)

self.log.debug(msg)
return False
finally:
jmlog.close()

self.log.debug("JMeter check: %s / %s", out, err)

if "is too low to run JMeter" in out:
raise ToolError("Java version is too low to run JMeter")

if "Error:" in out:
self.log.warning("JMeter output: \n%s", out)
raise ToolError("Unable to run JMeter, see error above")

return True

def _pmgr_call(self, params):
Expand Down
2 changes: 2 additions & 0 deletions bzt/modules/locustio.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ def _calculate_datapoints(self, final_pass=False):
yield point

def merge_datapoints(self, max_full_ts):
reader_id = self.file.name + "@" + str(id(self))
for key in sorted(self.join_buffer.keys(), key=int):
if int(key) <= max_full_ts:
sec_data = self.join_buffer.pop(key)
self.log.debug("Processing complete second: %s", key)
point = DataPoint(int(key))
point[DataPoint.SOURCE_ID] = reader_id
for sid, item in iteritems(sec_data):
point.merge_point(self.point_from_locust(key, sid, item))
point.recalculate()
Expand Down
6 changes: 5 additions & 1 deletion bzt/modules/python/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,13 @@ def _gen_transaction(self, trans_conf):
else:
body.append(self._gen_http_request(request))

transaction_class = "apiritif.transaction"
if self.test_mode == "selenium":
transaction_class += "_logged"

transaction = ast.With(
context_expr=ast_call(
func=ast_attr("apiritif.transaction"),
func=ast_attr(transaction_class),
args=[self._gen_expr(trans_conf.label)]),
optional_vars=None,
body=body)
Expand Down
9 changes: 5 additions & 4 deletions bzt/modules/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from bzt import ManualShutdown
from bzt.six import text_type, iteritems, PY2
from bzt.utils import is_windows
from bzt.utils import is_linux
import bzt.resources as bztr

if PY2: # we have to put import logic here to avoid requiring python-tk library on linux
Expand Down Expand Up @@ -62,11 +62,12 @@ def _start(self):
self.root = tkinter.Tk()
self.root.geometry("%sx%s" % (self.size[0] * 7, self.size[1] * 15))
self.root.bind("<Configure>", self.resize)
if is_windows():
self.root.bind("<Control-MouseWheel>", self.change_font)
else:
if is_linux():
self.root.bind("<Control-4>", self.change_font)
self.root.bind("<Control-5>", self.change_font)
else:
self.root.bind("<Control-MouseWheel>", self.change_font)

self.root.protocol("WM_DELETE_WINDOW", self.closed_window)
self.text = tkinter.Text(self.root, font="TkFixedFont", wrap=tkinter.NONE, state=tkinter.DISABLED,
background="black", foreground="light gray")
Expand Down
13 changes: 13 additions & 0 deletions site/dat/docs/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 1.13.7<sup>next</sup>
- filter out `included-configs` from cloud YAML

## 1.13.6<sup>6 may 2019</sup>

- fix issues of pip package for previous version
- default empty concurrency in JMeter JMX as 1
- handle JMeter install check failures properly
- fix OSX mouse wheel binding, document dashboard scaling
- fix Gatling getting `u` prefix to simulation name (and other properties)
- handle quitting event from locust to ignore restrictions on teardown


## 1.13.5<sup>30 apr 2019</sup>

- default `iterations` are now `1` as opposed to `infinity` in the past
Expand Down
1 change: 1 addition & 0 deletions site/dat/docs/ConsoleReporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ modules:
dummy-cols: 140 # width for dummy screen
dummy-rows: 35 # height for dummy screen
```
Tkinter dashboard (gui mode) can be scaled with `ctrl`+`Mouse-Scroll`

You can also disable this reporter by using [command-line](CommandLine.md) `-o` switch:
```bash
Expand Down
1 change: 1 addition & 0 deletions site/dat/docs/changes/fix-gatling-props-encoding.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string props must be encoded for py2 (even on win)
3 changes: 3 additions & 0 deletions site/dat/docs/changes/fix-locust-aggregation
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fix locust slave reader results

datapoints must have id of source, so let's add it to datapoints
1 change: 1 addition & 0 deletions site/dat/docs/changes/fix-styles-at-the-site.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix css styles at the site for good view
1 change: 1 addition & 0 deletions site/dat/docs/changes/fix-uploading-test.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
check real file stream

This file was deleted.

16 changes: 12 additions & 4 deletions site/img/taurus.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ body {
color: #565866;
background-color: #f9f9f9;
font-family: 'Open Sans', sans-serif;
font-size: 16px;
font-size: 14px;
}

.header {
Expand Down Expand Up @@ -119,6 +119,7 @@ h1, h2, h3, h4, h5, h6 {

/* WIKI */
table.wiki {
table-layout: fixed;
width: 100%;
}

Expand All @@ -139,7 +140,7 @@ table.wiki pre, table.wiki tt {

table.wiki pre {
padding: 1em;
overflow: hidden;
overflow: auto;
font-size: 0.8em;
}

Expand All @@ -156,6 +157,7 @@ table.wiki .sidebar {
border-radius: 0.3em;
white-space: nowrap;
padding: 2em;
width: 30%;
}

table.wiki .sidebar sup, table.wiki .sidebar font {
Expand All @@ -164,7 +166,7 @@ table.wiki .sidebar sup, table.wiki .sidebar font {

table.wiki .toc-list {
margin-bottom: 0.75em;
white-space: nowrap;
white-space: normal;
list-style-type: decimal;
font-size: 14px;
}
Expand Down Expand Up @@ -207,7 +209,7 @@ table.wiki img {
}

.stick {
position: fixed;
position: sticky;
top: 2em;
display: block;
}
Expand Down Expand Up @@ -344,4 +346,10 @@ table.wiki img {

.gitter-button i {
font-size: 1.2em;
}

@media (min-width: 1500px){
.container {
width: 1500px;
}
}
5 changes: 5 additions & 0 deletions tests/modules/jmeter/test_JMX.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def get_groupset(self, testname=None):
groupset.append(group)
return groupset

def test_empty_concuurency(self):
self.configure(load={"concurrency": 22}, jmx_file=RESOURCES_DIR + 'jmeter/jmx/empty_concurrency.jmx')
self.obj.modify(self.jmx)
self.assertEqual("22", self.get_groupset()[0].get_concurrency(raw=True))

def test_keep_original(self):
self.configure(jmx_file=RESOURCES_DIR + 'jmeter/jmx/threadgroups.jmx')
self.assertEqual(LoadSettingsProcessor.TG, self.obj.tg) # because no duration
Expand Down
8 changes: 7 additions & 1 deletion tests/modules/selenium/test_python_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def test_selenium_startup_shutdown_python_folder(self):
while not self.obj.check():
time.sleep(self.obj.engine.check_interval)
self.obj.shutdown()
self.assertTrue(os.path.exists(os.path.join(self.obj.engine.artifacts_dir, "apiritif.0.csv")))
api_log = os.path.join(self.obj.engine.artifacts_dir, "apiritif.0.csv")
nose_log = os.path.join(self.obj.engine.artifacts_dir, "nose.out")
self.assertTrue(os.path.exists(api_log))
with open(nose_log) as fds:
content = fds.read()
self.assertIn("Transaction started::", content)
self.assertIn("Transaction ended::", content)

def test_runner_fail_no_test_found(self):
"""
Expand Down
5 changes: 3 additions & 2 deletions tests/modules/test_Gatling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
import os
import sys
import shutil
import sys
import time

from bzt import ToolError, TaurusConfigError
Expand Down Expand Up @@ -542,7 +542,8 @@ def test_properties_migration(self):
def test_properties_2levels(self):
self.obj.settings.merge({
"properties": {
"settlevel": "settval",
"settlevel": u"settval",
"unc": u"Ä",
"override": 1,
},
})
Expand Down
24 changes: 18 additions & 6 deletions tests/modules/test_blazeMeterUploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import shutil
import time
from tempfile import mkstemp
from io import BytesIO

from bzt import TaurusException
Expand Down Expand Up @@ -420,12 +421,23 @@ def test_unicode_request(self):
session.upload_file(RESOURCES_DIR + "jmeter/unicode_file")

def test_binary_unicode_error(self):
session = Session(data={'id': 1})
mock = BZMock(session)
mock.mock_post['https://data.blazemeter.com/api/v4/image/1/files?signature=None'] = {"result": 1}
with open(RESOURCES_DIR + "jmeter/jmeter-dist-2.13.zip", 'rb') as fds:
zip_content = fds.read()
session.upload_file("jtls_and_more.zip", zip_content)
fd, fname = mkstemp()
os.close(fd)
file_handler = logging.FileHandler(fname, encoding="utf-8")
file_handler.setLevel(logging.DEBUG)
ROOT_LOGGER.addHandler(file_handler)

try:
session = Session(data={'id': 1})
mock = BZMock(session)
mock.mock_post['https://data.blazemeter.com/api/v4/image/1/files?signature=None'] = {"result": 1}
with open(RESOURCES_DIR + "jmeter/jmeter-dist-2.13.zip", 'rb') as fds:
zip_content = fds.read()
session.upload_file("jtls_and_more.zip", zip_content)
finally:
ROOT_LOGGER.removeHandler(file_handler)
file_handler.close()
os.remove(fname)


class DummyHttpResponse(object):
Expand Down
11 changes: 10 additions & 1 deletion tests/modules/test_locustIOExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from bzt import ToolError
from bzt.utils import dehumanize_time
from bzt.modules.jmeter import JTLReader
from bzt.modules.aggregator import DataPoint, KPISet
from bzt.modules.aggregator import DataPoint, KPISet, ConsolidatingAggregator
from bzt.modules.locustio import LocustIOExecutor, SlavesReader
from bzt.modules.provisioning import Local

Expand Down Expand Up @@ -151,6 +151,15 @@ def test_locust_resource_files(self):
resource_files = self.obj.resource_files()
self.assertEqual(1, len(resource_files))

def test_slave_aggregation(self):
self.configure({"execution": {
"scenario": {"script": RESOURCES_DIR + "locust/simple.py"}}})
self.obj.prepare()
self.obj.reader = SlavesReader(RESOURCES_DIR + "locust/locust-slaves.ldjson", 2, ROOT_LOGGER)
self.obj.engine.aggregator = ConsolidatingAggregator()
self.obj.engine.aggregator.add_underling(self.obj.reader)
self.assertEqual(1, len(list(self.obj.engine.aggregator.datapoints(final_pass=True))))

def test_resource_files_requests(self):
self.configure({"execution": {
"concurrency": 1,
Expand Down
Loading

0 comments on commit fec770a

Please sign in to comment.