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

CTRL-C handling in Behat inside docker #299

Open
skodak opened this issue Aug 24, 2024 · 2 comments
Open

CTRL-C handling in Behat inside docker #299

skodak opened this issue Aug 24, 2024 · 2 comments

Comments

@skodak
Copy link
Contributor

skodak commented Aug 24, 2024

Quite often I realise I need to do some changes in feature fields before behat execution in docker completes, so I press CTRL-C to stop it. But the CTRL-C does not work the same in PHP inside docker and so the selenium session does not get terminated properly and because there is a default maximum session limit of 1 in standalone chrome selenium then the next behat gets stuck for 300 seconds until the selenium session times out (or until you restart selenium).

Workaround is to increase the maximum number of sessions like this

services:
  selenium:
    ports:
      - "${MOODLE_DOCKER_SELENIUM_VNC_PORT}:5900"
    environment:
        # Workaround for https://github.com/SeleniumHQ/docker-selenium/issues/227
        "no_proxy": localhost
        # Allow new behat after CTRL-C, the aborted sessions will time out in 300 seconds by default.
        SE_NODE_MAX_SESSIONS: 8
        SE_NODE_OVERRIDE_MAX_SESSIONS: true

skodak@c180ab2

I wanted to ask you guys, is there is a better way to deal with CTRL-C so that standard PHP signal handling works as usual?

@skodak
Copy link
Contributor Author

skodak commented Aug 24, 2024

Aaaaah, the problem was that the moodle php image does not have PCNTL installed, this change adds support for it in root/tmp/setup/php-extensions.sh in moodle-php-apache image:

docker-php-ext-configure pcntl --enable-pcntl
docker-php-ext-install pcntl

but it is not all that is necessary there to fix the problem completely

Actually sometimes the ctrl-c works fine and the selenium session gets closed during shutdown, but in most cases it says "^CSegmentation fault" and the selenium session is left to time out, so I guess it would be sae to add higher limit anyway.

@skodak
Copy link
Contributor Author

skodak commented Aug 24, 2024

I think I found it, it seems that the shutdown manager is interfering with CTRL-C handling in vendor/behat/behat/src/Behat/Testwork/EventDispatcher/Cli/SigintController.php

this fixes it for me when using vendor/bin/behat:

        if (!defined('BEHAT_TEST') || !BEHAT_TEST) {
            pcntl_signal(SIGINT, ['core_shutdown_manager', 'signal_handler']);
        }


vendor/bin/behat --config /var/www/behatdata/behatrun/behat/behat.yml
skodak@mbair work % behat --tags=@javascript
Moodle 4.3.6 (Build: 20240812), a9c7e741f2bb748394ffbd9a093f4c5cb4e21f14
Php: 8.1.29, pgsql: 15.2 (Debian 15.2-1.pgdg110+1), OS: Linux 6.10.0-linuxkit aarch64
Run optional tests:
- Accessibility: Yes
Server OS "Linux", Browser: "chrome"
Started at 24-08-2024, 21:03
........^C

No scenarios
8 steps (8 passed)
0m5.88s (75.02Mb)

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

No branches or pull requests

1 participant