diff --git a/.github/workflows/test-devel.yml b/.github/workflows/test-devel.yml index 640e680..5d18ad2 100644 --- a/.github/workflows/test-devel.yml +++ b/.github/workflows/test-devel.yml @@ -435,8 +435,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -473,8 +473,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -505,8 +505,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -544,8 +544,8 @@ jobs: cd $GITHUB_WORKSPACE/ergo/ make build make install - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -582,8 +582,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -614,8 +614,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -652,8 +652,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -690,8 +690,8 @@ jobs: ./configure --prefix=$HOME/.local/ --with-maxcon=1024 --enable-debug make -j 4 make install - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -717,8 +717,8 @@ jobs: - name: Install dependencies run: pip install git+https://github.com/ProgVal/Limnoria.git@testing cryptography pyxmpp2-scram - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -749,8 +749,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -787,8 +787,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -819,8 +819,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -857,8 +857,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -889,8 +889,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -915,8 +915,8 @@ jobs: python-version: 3.7 - name: Install dependencies run: pip install git+https://github.com/sopel-irc/sopel.git - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -947,8 +947,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -979,8 +979,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1017,8 +1017,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1049,8 +1049,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip diff --git a/.github/workflows/test-devel_release.yml b/.github/workflows/test-devel_release.yml index 0b25abb..02d2524 100644 --- a/.github/workflows/test-devel_release.yml +++ b/.github/workflows/test-devel_release.yml @@ -121,8 +121,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -159,8 +159,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -191,8 +191,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip diff --git a/.github/workflows/test-stable.yml b/.github/workflows/test-stable.yml index 0e66d6d..7e0a1a3 100644 --- a/.github/workflows/test-stable.yml +++ b/.github/workflows/test-stable.yml @@ -478,8 +478,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -516,8 +516,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -548,8 +548,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -580,8 +580,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -619,8 +619,8 @@ jobs: cd $GITHUB_WORKSPACE/ergo/ make build make install - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -657,8 +657,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -689,8 +689,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -727,8 +727,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -759,8 +759,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -813,8 +813,8 @@ jobs: mkdir -p $HOME/.local/bin cp $HOME/.local/sbin/ircd $HOME/.local/bin/ircd' - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -851,8 +851,8 @@ jobs: ./configure --prefix=$HOME/.local/ --with-maxcon=1024 --enable-debug make -j 4 make install - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -877,8 +877,8 @@ jobs: python-version: 3.7 - name: Install dependencies run: pip install limnoria==2022.03.17 cryptography pyxmpp2-scram - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -909,8 +909,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -947,8 +947,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -979,8 +979,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1017,8 +1017,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1049,8 +1049,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1075,8 +1075,8 @@ jobs: python-version: 3.7 - name: Install dependencies run: pip install sopel==7.1.8 - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1107,8 +1107,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1139,8 +1139,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1177,8 +1177,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip @@ -1209,8 +1209,8 @@ jobs: path: '~' - name: Unpack artefacts run: cd ~; find -name 'artefacts-*.tar.gz' -exec tar -xzf '{}' \; - - name: Install Atheme - run: sudo apt-get install atheme-services + - name: Install system dependencies + run: sudo apt-get install atheme-services faketime - name: Install irctest dependencies run: |- python -m pip install --upgrade pip diff --git a/README.md b/README.md index 7aac195..18edbc5 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ have no side effect. Install irctest and dependencies: ``` +sudo apt install faketime # Optional, but greatly speeds up irctest/server_tests/list.py cd ~ git clone https://github.com/ProgVal/irctest.git cd irctest diff --git a/irctest/basecontrollers.py b/irctest/basecontrollers.py index b1464ac..e8680b3 100644 --- a/irctest/basecontrollers.py +++ b/irctest/basecontrollers.py @@ -189,6 +189,10 @@ class BaseServerController(_BaseController): """Character used for the 'mute' extban""" nickserv = "NickServ" + def __init__(self, *args: Any, **kwargs: Any): + super().__init__(*args, **kwargs) + self.faketime_enabled = False + def get_hostname_and_port(self) -> Tuple[str, int]: return find_hostname_and_port() @@ -202,6 +206,7 @@ class BaseServerController(_BaseController): run_services: bool, valid_metadata_keys: Optional[Set[str]], invalid_metadata_keys: Optional[Set[str]], + faketime: Optional[str], ) -> None: raise NotImplementedError() diff --git a/irctest/cases.py b/irctest/cases.py index 4dbd43a..a259b7f 100644 --- a/irctest/cases.py +++ b/irctest/cases.py @@ -508,6 +508,12 @@ class BaseServerTestCase( server_support: Optional[Dict[str, Optional[str]]] run_services = False + faketime: Optional[str] = None + """If not None and the controller supports it and libfaketime is available, + runs the server using faketime and this value set as the $FAKETIME env variable. + Tests must check ``self.controller.faketime_enabled`` is True before + relying on this.""" + __new__ = object.__new__ # pytest won't collect Generic[] subclasses otherwise def setUp(self) -> None: @@ -522,6 +528,7 @@ class BaseServerTestCase( invalid_metadata_keys=self.invalid_metadata_keys, ssl=self.ssl, run_services=self.run_services, + faketime=self.faketime, ) self.clients: Dict[TClientName, client_mock.ClientMock] = {} diff --git a/irctest/controllers/bahamut.py b/irctest/controllers/bahamut.py index 01cd4dd..6a23aaa 100644 --- a/irctest/controllers/bahamut.py +++ b/irctest/controllers/bahamut.py @@ -102,6 +102,7 @@ class BahamutController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -136,15 +137,21 @@ class BahamutController(BaseServerController, DirectoryBasedController): # pem_path=self.pem_path, ) ) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ - # "strace", "-f", "-e", "file", + *faketime_cmd, "ircd", "-t", # don't fork "-f", os.path.join(self.directory, "server.conf"), ], - # stdout=subprocess.DEVNULL, ) if run_services: diff --git a/irctest/controllers/base_hybrid.py b/irctest/controllers/base_hybrid.py index f91229a..e2c0418 100644 --- a/irctest/controllers/base_hybrid.py +++ b/irctest/controllers/base_hybrid.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set @@ -43,6 +44,7 @@ class BaseHybridController(BaseServerController, DirectoryBasedController): run_services: bool, valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -73,8 +75,16 @@ class BaseHybridController(BaseServerController, DirectoryBasedController): ) ) assert self.directory + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, self.binary_name, "-foreground", "-configfile", diff --git a/irctest/controllers/ergo.py b/irctest/controllers/ergo.py index d6e80ab..3878e7b 100644 --- a/irctest/controllers/ergo.py +++ b/irctest/controllers/ergo.py @@ -1,6 +1,7 @@ import copy import json import os +import shutil import subprocess from typing import Any, Dict, Optional, Set, Type, Union @@ -155,6 +156,7 @@ class ErgoController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], config: Optional[Any] = None, ) -> None: if valid_metadata_keys or invalid_metadata_keys: @@ -202,8 +204,15 @@ class ErgoController(BaseServerController, DirectoryBasedController): self._write_config() subprocess.call(["ergo", "initdb", "--conf", self._config_path, "--quiet"]) subprocess.call(["ergo", "mkcerts", "--conf", self._config_path, "--quiet"]) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( - ["ergo", "run", "--conf", self._config_path, "--quiet"] + [*faketime_cmd, "ergo", "run", "--conf", self._config_path, "--quiet"] ) def wait_for_services(self) -> None: diff --git a/irctest/controllers/external_server.py b/irctest/controllers/external_server.py index 5ecbae0..e8c822a 100644 --- a/irctest/controllers/external_server.py +++ b/irctest/controllers/external_server.py @@ -42,6 +42,7 @@ class ExternalServerController(BaseServerController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: pass diff --git a/irctest/controllers/inspircd.py b/irctest/controllers/inspircd.py index 1cd40ba..24167aa 100644 --- a/irctest/controllers/inspircd.py +++ b/irctest/controllers/inspircd.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -114,6 +115,7 @@ class InspircdController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str] = None, ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -147,8 +149,16 @@ class InspircdController(BaseServerController, DirectoryBasedController): ) ) assert self.directory + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "inspircd", "--nofork", "--config", diff --git a/irctest/controllers/irc2.py b/irctest/controllers/irc2.py index 56defc8..d901c0d 100644 --- a/irctest/controllers/irc2.py +++ b/irctest/controllers/irc2.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -51,6 +52,7 @@ class Ircu2Controller(BaseServerController, DirectoryBasedController): run_services: bool, valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -76,8 +78,16 @@ class Ircu2Controller(BaseServerController, DirectoryBasedController): pidfile=pidfile, ) ) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "ircd", "-s", # no iauth "-p", diff --git a/irctest/controllers/ircu2.py b/irctest/controllers/ircu2.py index 592cfd2..1b87338 100644 --- a/irctest/controllers/ircu2.py +++ b/irctest/controllers/ircu2.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -69,6 +70,7 @@ class Ircu2Controller(BaseServerController, DirectoryBasedController): run_services: bool, valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -94,8 +96,16 @@ class Ircu2Controller(BaseServerController, DirectoryBasedController): pidfile=pidfile, ) ) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "ircd", "-n", # don't detach "-f", diff --git a/irctest/controllers/mammon.py b/irctest/controllers/mammon.py index c437139..591347e 100644 --- a/irctest/controllers/mammon.py +++ b/irctest/controllers/mammon.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -92,6 +93,7 @@ class MammonController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if password is not None: raise NotImplementedByController("PASS command") @@ -113,8 +115,16 @@ class MammonController(BaseServerController, DirectoryBasedController): # with self.open_file('server.yml', 'r') as fd: # print(fd.read()) assert self.directory + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "mammond", "--nofork", # '--debug', "--config", diff --git a/irctest/controllers/ngircd.py b/irctest/controllers/ngircd.py index 17b3540..0999863 100644 --- a/irctest/controllers/ngircd.py +++ b/irctest/controllers/ngircd.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -56,6 +57,7 @@ class NgircdController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -81,6 +83,7 @@ class NgircdController(BaseServerController, DirectoryBasedController): fd.write("\n") assert self.directory + with self.open_file("server.conf") as fd: fd.write( TEMPLATE_CONFIG.format( @@ -94,8 +97,16 @@ class NgircdController(BaseServerController, DirectoryBasedController): empty_file=os.path.join(self.directory, "empty.txt"), ) ) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "ngircd", "--nodaemon", "--config", diff --git a/irctest/controllers/snircd.py b/irctest/controllers/snircd.py index 7fa9acc..2edb85c 100644 --- a/irctest/controllers/snircd.py +++ b/irctest/controllers/snircd.py @@ -1,4 +1,5 @@ import os +import shutil import subprocess from typing import Optional, Set, Type @@ -69,6 +70,7 @@ class SnircdController(BaseServerController, DirectoryBasedController): run_services: bool, valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -94,8 +96,16 @@ class SnircdController(BaseServerController, DirectoryBasedController): pidfile=pidfile, ) ) + + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ + *faketime_cmd, "ircd", "-n", # don't detach "-f", diff --git a/irctest/controllers/unrealircd.py b/irctest/controllers/unrealircd.py index af397c1..d9db353 100644 --- a/irctest/controllers/unrealircd.py +++ b/irctest/controllers/unrealircd.py @@ -1,8 +1,12 @@ import functools import os +<<<<<<< HEAD import pathlib import shutil import signal +======= +import shutil +>>>>>>> 96e6642 (Add support for 'faketime', to avoid long sleeps in upcoming ELIST tests) import subprocess import textwrap from typing import Optional, Set, Type @@ -156,6 +160,7 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): valid_metadata_keys: Optional[Set[str]] = None, invalid_metadata_keys: Optional[Set[str]] = None, restricted_metadata_keys: Optional[Set[str]] = None, + faketime: Optional[str], ) -> None: if valid_metadata_keys or invalid_metadata_keys: raise NotImplementedByController( @@ -192,6 +197,7 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): fd.write("\n") assert self.directory + with self.open_file("unrealircd.conf") as fd: fd.write( TEMPLATE_CONFIG.format( @@ -225,9 +231,16 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): proot_cmd = ["proot", "-b", f"{tmpdir}:{unrealircd_prefix}/tmp"] self.using_proot = True + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + self.proc = subprocess.Popen( [ *proot_cmd, + *faketime_cmd, "unrealircd", "-t", "-F", # BOOT_NOFORK diff --git a/make_workflows.py b/make_workflows.py index 4a74f90..3e1895a 100644 --- a/make_workflows.py +++ b/make_workflows.py @@ -209,8 +209,8 @@ def get_test_job(*, config, test_config, test_id, version_flavor, jobs): *unpack, *install_steps, { - "name": "Install Atheme", - "run": "sudo apt-get install atheme-services", + "name": "Install system dependencies", + "run": "sudo apt-get install atheme-services faketime", }, { "name": "Install irctest dependencies",