Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2.exceptions.TemplateAssertionError: no test named 'boolean' when attempting to visit UI #2087

Closed
SethTales opened this issue May 2, 2022 · 1 comment
Labels

Comments

@SethTales
Copy link

Describe the bug

After running the locust command, I see:

[2022-05-02 14:19:44,219] CCI-PF310CHF/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2022-05-02 14:19:44,227] CCI-PF310CHF/INFO/locust.main: Starting Locust 2.8.6

then, when I got to visit the UI at http://localhost:8089, it generates the following stacktrace:

Traceback (most recent call last):
  File "/home/sethtales/.local/lib/python3.8/site-packages/gevent/pywsgi.py", line 999, in handle_one_response
    self.run_application()
  File "/home/sethtales/.local/lib/python3.8/site-packages/gevent/pywsgi.py", line 945, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 2095, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 2080, in wsgi_app
    response = self.handle_exception(e)
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/sethtales/.local/lib/python3.8/site-packages/locust/web.py", line 399, in wrapper
    return view_func(*args, **kwargs)
  File "/home/sethtales/.local/lib/python3.8/site-packages/locust/web.py", line 135, in index
    return render_template("index.html", **self.template_args)
  File "/home/sethtales/.local/lib/python3.8/site-packages/flask/templating.py", line 149, in render_template
    ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 869, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/lib/python3/dist-packages/jinja2/loaders.py", line 125, in load
    code = environment.compile(source, name, filename)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 591, in compile
    self.handle_exception(exc_info, source_hint=source_hint)
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/home/sethtales/.local/lib/python3.8/site-packages/locust/templates/index.html", line 85, in <module>
    {% if not ((value is none) or (value is boolean)) %}
  File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 542, in _generate
    return generate(source, self, name, filename, defer_init=defer_init,
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 82, in generate
    generator.visit(node)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 754, in visit_Template
    self.blockvisit(node.body, frame)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 378, in blockvisit
    self.visit(node, frame)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 1122, in visit_For
    self.blockvisit(node.body, loop_frame)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 378, in blockvisit
    self.visit(node, frame)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 1157, in visit_If
    self.visit(node.test, if_frame)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 70, in new_func
    return f(self, node, frame, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 1497, in visitor
    self.visit(node.node, frame)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 70, in new_func
    return f(self, node, frame, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 1484, in visitor
    self.visit(node.right, frame)
  File "/usr/lib/python3/dist-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 70, in new_func
    return f(self, node, frame, **kwargs)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 1607, in visit_Test
    self.fail('no test named %r' % node.name, node.lineno)
  File "/usr/lib/python3/dist-packages/jinja2/compiler.py", line 315, in fail
    raise TemplateAssertionError(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateAssertionError: no test named 'boolean'
2022-05-02T21:19:47Z {'REMOTE_ADDR': '::1', 'REMOTE_PORT': '54720', 'HTTP_HOST': 'localhost:8089', (hidden keys: 33)} failed with TemplateAssertionError

Expected behavior

I should be able to visit the UI

Actual behavior

Described above

Steps to reproduce

Install locust, attempt to run and it does not work

Environment

  • OS: Windows 10, using WSL
  • Python version: 3.8.10
  • Locust version: 2.8.6
  • Locust command line that you ran: locust
  • Locust file contents (anonymized if necessary):
import time
from locust import HttpUser, task, between
import csv

class Last30DaysJobAggUser(HttpUser):
    wait_time = between(0,1)
    request_params = []

    @task
    def get_job_aggregated_items_all_branches(self):
        for params in self.request_params:
            self.client.get(f'http://127.0.0.1:8085/resource-usage/{params["org_id"]}/{params["project_id"]}/workflows/{params["wf_name"]}/jobs&reporting-window=last-30-days')

    def on_start(self):
        with open('../last_30_days_most_jobs.csv') as input:
            reader = csv.reader(input, delimiter=',')
            next(reader, None) # skip headers
            for row in reader:
                request_params = {}
                request_params["org_id"] = row[0]
                request_params["project_id"] = row[1]
                request_params["wf_name"] = row[2]
                self.request_params.append(request_params)
@SethTales SethTales added the bug label May 2, 2022
@pgaxatte
Copy link

pgaxatte commented May 5, 2022

I had the same issue and I fixed it by forcing the upgrade of Jinja2 (i'm using a virtualenv):

python -m virtualenv locust-venv
source locust-venv/bin/activate
pip install locust

Jinja2 (according to setup.cfg) is set to <3.1.0 which results in:

pip list | grep -i jinja
Jinja2                 2.10.1

By forcing the upgrade using pip install --upgrade Jijna2 I get:

pip list | grep -i jinja
Jinja2                 3.1.2

And now locust is working fine.

I guess the constraint on Jinja2 is not necessary anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants