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

New jinja2 pinning makes it impossible to build our codebase #2061

Closed
kramer65 opened this issue Mar 29, 2022 · 3 comments · Fixed by #2090
Closed

New jinja2 pinning makes it impossible to build our codebase #2061

kramer65 opened this issue Mar 29, 2022 · 3 comments · Fixed by #2090
Labels

Comments

@kramer65
Copy link

This isn't a bug in the codebase of locust per se, but rather a new jinja2 pinning here which makes it impossible to use locust in our codebase in which a different library requires a version of jinja2 higher than 3.1.0.

Is there a way that we can get rid of this pinning in locust? Or is there any known workaround?

@kramer65 kramer65 added the bug label Mar 29, 2022
@cyberw
Copy link
Collaborator

cyberw commented Mar 29, 2022

The reason I pinned it was because it is not backwards compatible and broke Locust. (I couldn't bother myself to figure out exactly how :)

If you can make Locust compatible with 3.1 then we can remove the pinning. This is probably a good starting point https://jinja.palletsprojects.com/en/3.1.x/changes/#version-3-1-0

https://github.com/locustio/locust/runs/5693857807?check_suite_focus=true

@Apteryks
Copy link

Apteryks commented Apr 20, 2022

For what it's worth, unpinning Jinja2 to use version 3.1.1 in GNU Guix on Python 3.9.9 and Locust 2.8.6, I had only one new test failure, which looks benign and unrelated:

=================================== FAILURES ===================================
________________ TestMasterWorkerRunners.test_distributed_shape ________________

self = <locust.test.test_runners.TestMasterWorkerRunners testMethod=test_distributed_shape>

    def test_distributed_shape(self):
        """
        Full integration test that starts both a MasterRunner and three WorkerRunner instances
        and tests a basic LoadTestShape with scaling up and down users
        """
    
        class TestUser(User):
            @task
            def my_task(self):
                pass
    
        class TestShape(LoadTestShape):
            def tick(self):
                run_time = self.get_run_time()
                if run_time < 2:
                    return 9, 9
                elif run_time < 4:
                    return 21, 21
                elif run_time < 6:
                    return 3, 21
                else:
                    return None
    
        with mock.patch("locust.runners.WORKER_REPORT_INTERVAL", new=0.3):
            test_shape = TestShape()
            master_env = Environment(user_classes=[TestUser], shape_class=test_shape)
            master_env.shape_class.reset_time()
            master = master_env.create_master_runner("*", 0)
    
            workers = []
            for i in range(3):
                worker_env = Environment(user_classes=[TestUser])
                worker = worker_env.create_worker_runner("127.0.0.1", master.server.port)
                workers.append(worker)
    
            # Give workers time to connect
            sleep(0.1)
    
            # Start a shape test
            master.start_shape()
            sleep(1)
    
            # Ensure workers have connected and started the correct amount of users
            for worker in workers:
                self.assertEqual(3, worker.user_count, "Shape test has not reached stage 1")
                self.assertEqual(
                    9, test_shape.get_current_user_count(), "Shape is not seeing stage 1 runner user count correctly"
                )
            self.assertDictEqual(master.reported_user_classes_count, {"TestUser": 9})
    
            # Ensure new stage with more users has been reached
            sleep(2)
            for worker in workers:
                self.assertEqual(7, worker.user_count, "Shape test has not reached stage 2")
                self.assertEqual(
                    21, test_shape.get_current_user_count(), "Shape is not seeing stage 2 runner user count correctly"
                )
            self.assertDictEqual(master.reported_user_classes_count, {"TestUser": 21})
    
            # Ensure new stage with less users has been reached
            sleep(2)
            for worker in workers:
                self.assertEqual(1, worker.user_count, "Shape test has not reached stage 3")
                self.assertEqual(
                    3, test_shape.get_current_user_count(), "Shape is not seeing stage 3 runner user count correctly"
                )
            self.assertDictEqual(master.reported_user_classes_count, {"TestUser": 3})
    
            # Ensure test stops at the end
            sleep(2)
            for worker in workers:
                self.assertEqual(0, worker.user_count, "Shape test has not stopped")
                self.assertEqual(
                    0, test_shape.get_current_user_count(), "Shape is not seeing stopped runner user count correctly"
                )
            self.assertDictEqual(master.reported_user_classes_count, {"TestUser": 0})
    
>           self.assertEqual("stopped", master.state)
E           AssertionError: 'stopped' != 'stopping'
E           - stopped
E           + stopping

locust/test/test_runners.py:1121: AssertionError
[...]
=============================== warnings summary ===============================
../../../gnu/store/l4nsxlz4hlxabj97vaylj1mwlvcwm4sy-python-pyquery-1.2.17/lib/python3.9/site-packages/pyquery/pyquery.py:50: 15 warnings
  /gnu/store/l4nsxlz4hlxabj97vaylj1mwlvcwm4sy-python-pyquery-1.2.17/lib/python3.9/site-packages/pyquery/pyquery.py:50: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
    name, inspect.getargspec(func).defaults)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED locust/test/test_runners.py::TestMasterWorkerRunners::test_distributed_shape
= 1 failed, 434 passed, 1 skipped, 8 deselected, 15 warnings in 349.99s (0:05:49) =
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "python" arguments: ("-m" "pytest" "locust" "-k" "not test_default_headless_spawn_options and not test_default_headless_spawn_options_with_shape and not test_headless_spawn_options_wo_run_time and not test_html_report_option and not test_web_options and not test_skip_logging and not test_custom_exit_code and not test_webserver") exit-status: 1 term-signal: #f stop-signal: #f>

@cyberw
Copy link
Collaborator

cyberw commented Apr 20, 2022

Yes, that issue doesnt look very serious. But it doesnt appear that jinja2 has had any relevant changes since 3.1.0, so its unlikely to be fixed. If somene makes a PR unpinning it and it works I'll be happy to look at it though.

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