Skip to content

feat(browser_manager): enable full XPI cleanup #1176

feat(browser_manager): enable full XPI cleanup

feat(browser_manager): enable full XPI cleanup #1176

GitHub Actions / test/test_[p]* failed Aug 7, 2024 in 0s

18 passed, 3 failed and 0 skipped

Tests failed

❌ junit-report.xml

21 tests were completed in 1824s with 18 passed, 3 failed and 0 skipped.

Test suite Passed Failed Skipped Time
pytest 18✅ 3❌ 1824s

❌ pytest

test.test_profile
  ✅ test_saving
  ✅ test_save_incomplete_profile_error
  ✅ test_crash_profile
  ✅ test_profile_error
  ✅ test_profile_saved_when_launch_crashes
  ✅ test_seed_persistence
  ✅ test_dump_profile_command
  ✅ test_load_tar_file
  ✅ test_crash_during_init
  ✅ test_profile_recovery[on_normal_operation-stateful-without_seed_tar]
  ✅ test_profile_recovery[on_normal_operation-stateful-with_seed_tar]
  ✅ test_profile_recovery[on_normal_operation-stateless-with_seed_tar]
  ✅ test_profile_recovery[on_crash-stateful-without_seed_tar]
  ✅ test_profile_recovery[on_crash-stateful-with_seed_tar]
  ✅ test_profile_recovery[on_crash-stateless-with_seed_tar]
  ❌ test_profile_recovery[on_crash_during_launch-stateful-without_seed_tar]
	monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70264a8b50>
  ❌ test_profile_recovery[on_crash_during_launch-stateful-with_seed_tar]
	monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f700122a450>
  ❌ test_profile_recovery[on_crash_during_launch-stateless-with_seed_tar]
	monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70275a5ed0>
  ✅ test_profile_recovery[on_timeout-stateful-without_seed_tar]
  ✅ test_profile_recovery[on_timeout-stateful-with_seed_tar]
  ✅ test_profile_recovery[on_timeout-stateless-with_seed_tar]

Annotations

Check failure on line 0 in junit-report.xml

See this annotation in the file changed.

@github-actions github-actions / test/test_[p]*

pytest ► test.test_profile ► test_profile_recovery[on_crash_during_launch-stateful-without_seed_tar]

Failed test found in:
  junit-report.xml
Error:
  monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70264a8b50>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70264a8b50>
default_params = (ManagerParams(data_directory=PosixPath('/tmp/pytest-of-runner/pytest-0/test_profile_recovery_on_crash3'), log_path=Po...mum_profile_size=None, tmpdir=None, recovery_tar=None, donottrack=False, tracking_protection=False, custom_params={})])
task_manager_creator = <function task_manager_creator.<locals>._create_task_manager at 0x7f70012b76a0>
testcase = 'on_crash_during_launch', stateful = True, seed_tar = None

    @pytest.mark.parametrize(
        "stateful,seed_tar",
        [(True, None), (True, Path("profile.tar.gz")), (False, Path("profile.tar.gz"))],
        ids=[
            "stateful-without_seed_tar",
            "stateful-with_seed_tar",
            "stateless-with_seed_tar",
        ],
    )
    @pytest.mark.parametrize(
        "testcase",
        ["on_normal_operation", "on_crash", "on_crash_during_launch", "on_timeout"],
    )
    # Use -k to run this test for a specific set of parameters. For example:
    # pytest -vv test_profile.py::test_profile_recovery -k on_crash-stateful-with_seed_tar
    def test_profile_recovery(
        monkeypatch, default_params, task_manager_creator, testcase, stateful, seed_tar
    ):
        """Test browser profile recovery in various scenarios."""
        manager_params, browser_params = default_params
        manager_params.num_browsers = 1
        browser_params[0].seed_tar = seed_tar
        manager, db = task_manager_creator((manager_params, browser_params[:1]))
        manager.get(BASE_TEST_URL, reset=not stateful)
    
        if testcase == "normal_operation":
            pass
        elif testcase == "on_crash":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
        elif testcase == "on_crash_during_launch":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
            # This will cause browser restarts to fail
            monkeypatch.setenv("FIREFOX_BINARY", "/tmp/NOTREAL")
    
            # Let the launch succeed after some failed launch attempts
            def undo_monkeypatch():
                time.sleep(5)  # This should be smaller than _SPAWN_TIMEOUT
                monkeypatch.undo()
    
            Thread(target=undo_monkeypatch).start()
        elif testcase == "on_timeout":
            # Set a very low timeout to cause a restart
            manager.get("about:config", reset=not stateful, timeout=0.1)
    
        cs = CommandSequence("about:config", reset=not stateful)
        expected_value = True if seed_tar else False
        cs.append_command(AssertConfigSetCommand("test_pref", expected_value))
        tar_directory = manager_params.data_directory / "browser_profile"
        tar_path = tar_directory / "profile.tar.gz"
        cs.dump_profile(tar_path, True)
>       manager.execute_command_sequence(cs)

/home/runner/work/OpenWPM/OpenWPM/test/test_profile.py:262: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:439: in execute_command_sequence
    thread = self._start_thread(browser, command_sequence)
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:375: in _start_thread
    self._check_failure_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <openwpm.task_manager.TaskManager object at 0x7f70264a9810>

    def _check_failure_status(self) -> None:
        """Check the status of command failures. Raise exceptions as necessary
    
        The failure status property is used by the various asynchronous
        command execution threads which interface with the
        remote browser manager processes. If a failure status is found, the
        appropriate steps are taken to gracefully close the infrastructure
        """
        self.logger.debug("Checking command failure status indicator...")
        if not self.failure_status:
            return
    
        self.logger.debug("TaskManager failure status set, halting command execution.")
        self._shutdown_manager()
        if self.failure_status["ErrorType"] == "ExceedCommandFailureLimit":
            raise CommandExecutionError(
                "TaskManager exceeded maximum consecutive command "
                "execution failures.",
                self.failure_status["CommandSequence"],
            )
        elif self.failure_status["ErrorType"] == "ExceedLaunchFailureLimit":
>           raise CommandExecutionError(
                "TaskManager failed to launch browser within allowable "
                "failure limit.",
                self.failure_status["CommandSequence"],
            )
E           openwpm.errors.CommandExecutionError: ('TaskManager failed to launch browser within allowable failure limit.', <openwpm.command_sequence.CommandSequence object at 0x7f7026485490>)

/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:355: CommandExecutionError

Check failure on line 0 in junit-report.xml

See this annotation in the file changed.

@github-actions github-actions / test/test_[p]*

pytest ► test.test_profile ► test_profile_recovery[on_crash_during_launch-stateful-with_seed_tar]

Failed test found in:
  junit-report.xml
Error:
  monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f700122a450>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f700122a450>
default_params = (ManagerParams(data_directory=PosixPath('/tmp/pytest-of-runner/pytest-0/test_profile_recovery_on_crash4'), log_path=Po...mum_profile_size=None, tmpdir=None, recovery_tar=None, donottrack=False, tracking_protection=False, custom_params={})])
task_manager_creator = <function task_manager_creator.<locals>._create_task_manager at 0x7f7026459300>
testcase = 'on_crash_during_launch', stateful = True
seed_tar = PosixPath('profile.tar.gz')

    @pytest.mark.parametrize(
        "stateful,seed_tar",
        [(True, None), (True, Path("profile.tar.gz")), (False, Path("profile.tar.gz"))],
        ids=[
            "stateful-without_seed_tar",
            "stateful-with_seed_tar",
            "stateless-with_seed_tar",
        ],
    )
    @pytest.mark.parametrize(
        "testcase",
        ["on_normal_operation", "on_crash", "on_crash_during_launch", "on_timeout"],
    )
    # Use -k to run this test for a specific set of parameters. For example:
    # pytest -vv test_profile.py::test_profile_recovery -k on_crash-stateful-with_seed_tar
    def test_profile_recovery(
        monkeypatch, default_params, task_manager_creator, testcase, stateful, seed_tar
    ):
        """Test browser profile recovery in various scenarios."""
        manager_params, browser_params = default_params
        manager_params.num_browsers = 1
        browser_params[0].seed_tar = seed_tar
        manager, db = task_manager_creator((manager_params, browser_params[:1]))
        manager.get(BASE_TEST_URL, reset=not stateful)
    
        if testcase == "normal_operation":
            pass
        elif testcase == "on_crash":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
        elif testcase == "on_crash_during_launch":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
            # This will cause browser restarts to fail
            monkeypatch.setenv("FIREFOX_BINARY", "/tmp/NOTREAL")
    
            # Let the launch succeed after some failed launch attempts
            def undo_monkeypatch():
                time.sleep(5)  # This should be smaller than _SPAWN_TIMEOUT
                monkeypatch.undo()
    
            Thread(target=undo_monkeypatch).start()
        elif testcase == "on_timeout":
            # Set a very low timeout to cause a restart
            manager.get("about:config", reset=not stateful, timeout=0.1)
    
        cs = CommandSequence("about:config", reset=not stateful)
        expected_value = True if seed_tar else False
        cs.append_command(AssertConfigSetCommand("test_pref", expected_value))
        tar_directory = manager_params.data_directory / "browser_profile"
        tar_path = tar_directory / "profile.tar.gz"
        cs.dump_profile(tar_path, True)
>       manager.execute_command_sequence(cs)

/home/runner/work/OpenWPM/OpenWPM/test/test_profile.py:262: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:439: in execute_command_sequence
    thread = self._start_thread(browser, command_sequence)
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:375: in _start_thread
    self._check_failure_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <openwpm.task_manager.TaskManager object at 0x7f700122b910>

    def _check_failure_status(self) -> None:
        """Check the status of command failures. Raise exceptions as necessary
    
        The failure status property is used by the various asynchronous
        command execution threads which interface with the
        remote browser manager processes. If a failure status is found, the
        appropriate steps are taken to gracefully close the infrastructure
        """
        self.logger.debug("Checking command failure status indicator...")
        if not self.failure_status:
            return
    
        self.logger.debug("TaskManager failure status set, halting command execution.")
        self._shutdown_manager()
        if self.failure_status["ErrorType"] == "ExceedCommandFailureLimit":
            raise CommandExecutionError(
                "TaskManager exceeded maximum consecutive command "
                "execution failures.",
                self.failure_status["CommandSequence"],
            )
        elif self.failure_status["ErrorType"] == "ExceedLaunchFailureLimit":
>           raise CommandExecutionError(
                "TaskManager failed to launch browser within allowable "
                "failure limit.",
                self.failure_status["CommandSequence"],
            )
E           openwpm.errors.CommandExecutionError: ('TaskManager failed to launch browser within allowable failure limit.', <openwpm.command_sequence.CommandSequence object at 0x7f7001207250>)

/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:355: CommandExecutionError

Check failure on line 0 in junit-report.xml

See this annotation in the file changed.

@github-actions github-actions / test/test_[p]*

pytest ► test.test_profile ► test_profile_recovery[on_crash_during_launch-stateless-with_seed_tar]

Failed test found in:
  junit-report.xml
Error:
  monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70275a5ed0>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f70275a5ed0>
default_params = (ManagerParams(data_directory=PosixPath('/tmp/pytest-of-runner/pytest-0/test_profile_recovery_on_crash5'), log_path=Po...mum_profile_size=None, tmpdir=None, recovery_tar=None, donottrack=False, tracking_protection=False, custom_params={})])
task_manager_creator = <function task_manager_creator.<locals>._create_task_manager at 0x7f702645bc40>
testcase = 'on_crash_during_launch', stateful = False
seed_tar = PosixPath('profile.tar.gz')

    @pytest.mark.parametrize(
        "stateful,seed_tar",
        [(True, None), (True, Path("profile.tar.gz")), (False, Path("profile.tar.gz"))],
        ids=[
            "stateful-without_seed_tar",
            "stateful-with_seed_tar",
            "stateless-with_seed_tar",
        ],
    )
    @pytest.mark.parametrize(
        "testcase",
        ["on_normal_operation", "on_crash", "on_crash_during_launch", "on_timeout"],
    )
    # Use -k to run this test for a specific set of parameters. For example:
    # pytest -vv test_profile.py::test_profile_recovery -k on_crash-stateful-with_seed_tar
    def test_profile_recovery(
        monkeypatch, default_params, task_manager_creator, testcase, stateful, seed_tar
    ):
        """Test browser profile recovery in various scenarios."""
        manager_params, browser_params = default_params
        manager_params.num_browsers = 1
        browser_params[0].seed_tar = seed_tar
        manager, db = task_manager_creator((manager_params, browser_params[:1]))
        manager.get(BASE_TEST_URL, reset=not stateful)
    
        if testcase == "normal_operation":
            pass
        elif testcase == "on_crash":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
        elif testcase == "on_crash_during_launch":
            # Cause a selenium crash to force browser to restart
            manager.get("example.com", reset=not stateful)
            # This will cause browser restarts to fail
            monkeypatch.setenv("FIREFOX_BINARY", "/tmp/NOTREAL")
    
            # Let the launch succeed after some failed launch attempts
            def undo_monkeypatch():
                time.sleep(5)  # This should be smaller than _SPAWN_TIMEOUT
                monkeypatch.undo()
    
            Thread(target=undo_monkeypatch).start()
        elif testcase == "on_timeout":
            # Set a very low timeout to cause a restart
            manager.get("about:config", reset=not stateful, timeout=0.1)
    
        cs = CommandSequence("about:config", reset=not stateful)
        expected_value = True if seed_tar else False
        cs.append_command(AssertConfigSetCommand("test_pref", expected_value))
        tar_directory = manager_params.data_directory / "browser_profile"
        tar_path = tar_directory / "profile.tar.gz"
        cs.dump_profile(tar_path, True)
>       manager.execute_command_sequence(cs)

/home/runner/work/OpenWPM/OpenWPM/test/test_profile.py:262: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:439: in execute_command_sequence
    thread = self._start_thread(browser, command_sequence)
/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:375: in _start_thread
    self._check_failure_status()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <openwpm.task_manager.TaskManager object at 0x7f70275a6dd0>

    def _check_failure_status(self) -> None:
        """Check the status of command failures. Raise exceptions as necessary
    
        The failure status property is used by the various asynchronous
        command execution threads which interface with the
        remote browser manager processes. If a failure status is found, the
        appropriate steps are taken to gracefully close the infrastructure
        """
        self.logger.debug("Checking command failure status indicator...")
        if not self.failure_status:
            return
    
        self.logger.debug("TaskManager failure status set, halting command execution.")
        self._shutdown_manager()
        if self.failure_status["ErrorType"] == "ExceedCommandFailureLimit":
            raise CommandExecutionError(
                "TaskManager exceeded maximum consecutive command "
                "execution failures.",
                self.failure_status["CommandSequence"],
            )
        elif self.failure_status["ErrorType"] == "ExceedLaunchFailureLimit":
>           raise CommandExecutionError(
                "TaskManager failed to launch browser within allowable "
                "failure limit.",
                self.failure_status["CommandSequence"],
            )
E           openwpm.errors.CommandExecutionError: ('TaskManager failed to launch browser within allowable failure limit.', <openwpm.command_sequence.CommandSequence object at 0x7f700125ac10>)

/home/runner/work/OpenWPM/OpenWPM/openwpm/task_manager.py:355: CommandExecutionError