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

feat(browser_manager): enable full XPI cleanup #1104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

feat(browser_manager): enable full XPI cleanup

58181c6
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Open

feat(browser_manager): enable full XPI cleanup #1104

feat(browser_manager): enable full XPI cleanup
58181c6
Select commit
Loading
Failed to load commit list.
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 1809s with 18 passed, 3 failed and 0 skipped.

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

❌ 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 0x7f5471a41010>
  ❌ test_profile_recovery[on_crash_during_launch-stateful-with_seed_tar]
	monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f544c8f9750>
  ❌ test_profile_recovery[on_crash_during_launch-stateless-with_seed_tar]
	monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f5471aa3b90>
  ✅ 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 0x7f5471a41010>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f5471a41010>
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 0x7f544c7ec5e0>
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 0x7f5471a41dd0>

    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 0x7f5471a43a50>)

/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 0x7f544c8f9750>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f544c8f9750>
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 0x7f544c7efec0>
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 0x7f5472b98c10>

    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 0x7f5472c62ed0>)

/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 0x7f5471aa3b90>
Raw output
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f5471aa3b90>
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 0x7f5472bc2520>
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 0x7f5472bd6950>

    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 0x7f544c7971d0>)

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