Ejemplo n.º 1
0
def test_exit_continuous_ssh_continuous_when_experiment_is_exited():
    handlers_called = []

    class Handler(RunEventHandler):
        def started(self, experiment: Experiment,
                    journal: Journal) -> NoReturn:
            handlers_called.append("started")

        def interrupted(self, experiment: Experiment,
                        journal: Journal) -> NoReturn:
            handlers_called.append("interrupted")

    experiment = experiments.SimpleExperimentWithExit.copy()
    journal = run_experiment(
        experiment,
        strategy=Strategy.CONTINUOUS,
        schedule=Schedule(continuous_hypothesis_frequency=0.1),
        event_handlers=[Handler()],
    )
    assert journal is not None
    assert journal["steady_states"]["before"] is not None
    assert journal["steady_states"]["after"] is None
    assert journal["steady_states"]["during"] is not None
    assert journal["deviated"] is False
    assert journal["status"] == "interrupted"
    assert sorted(handlers_called) == ["started"]
Ejemplo n.º 2
0
def test_run_ssh_continous():
    experiment = experiments.SimpleExperiment.copy()
    journal = run_experiment(
        experiment,
        strategy=Strategy.CONTINOUS,
        schedule=Schedule(continous_hypothesis_frequency=0.1))
    assert journal is not None
    assert journal["steady_states"]["before"] is not None
    assert journal["steady_states"]["after"] is not None
    assert journal["steady_states"]["during"] is not None
Ejemplo n.º 3
0
def test_do_not_exit_when_continous_ssh_fails_and_no_failfast():
    experiment = experiments.SimpleExperimentWithSSHFailingAtSomePoint.copy()
    journal = run_experiment(
        experiment,
        strategy=Strategy.CONTINOUS,
        schedule=Schedule(continous_hypothesis_frequency=0.1, fail_fast=False),
        settings={"runtime": {
            "rollbacks": {
                "strategy": "always"
            }
        }})
    assert journal is not None
    assert journal["steady_states"]["before"] is not None
    assert journal["steady_states"]["after"] is not None
    assert journal["steady_states"]["during"] is not None
    assert journal["status"] == "failed"
    assert journal["deviated"] == True
    assert len(journal["run"]) == 2
Ejemplo n.º 4
0
def test_exit_continous_ssh_continous_when_activity_raises_unknown_exception():
    experiment = experiments.SimpleExperimentWithException.copy()
    journal = run_experiment(
        experiment,
        strategy=Strategy.CONTINOUS,
        schedule=Schedule(continous_hypothesis_frequency=0.1),
        settings={"runtime": {
            "rollbacks": {
                "strategy": "always"
            }
        }})
    assert journal is not None
    assert journal["steady_states"]["before"] is not None
    assert journal["steady_states"]["after"] is not None
    assert journal["steady_states"]["during"] is not None
    assert journal["deviated"] == False
    assert journal["status"] == "completed"
    assert len(journal["run"]) == 2
    assert journal["run"][-1]["status"] == "failed"
    assert "oops" in journal["run"][-1]["exception"][-1]
Ejemplo n.º 5
0
def test_exit_immediately_when_continuous_ssh_fails_and_failfast_when_background_activity(
):  # noqa E501
    experiment = (
        experiments.
        SimpleExperimentWithSSHFailingAtSomePointWithBackgroundActivity.copy(
        )  # noqa E501
    )
    journal = run_experiment(
        experiment,
        strategy=Strategy.CONTINUOUS,
        schedule=Schedule(continuous_hypothesis_frequency=0.1, fail_fast=True),
        settings={"runtime": {
            "rollbacks": {
                "strategy": "always"
            }
        }},
    )
    assert journal is not None
    assert journal["steady_states"]["before"] is not None
    assert journal["steady_states"]["after"] is not None
    assert journal["steady_states"]["during"] is not None
    assert journal["status"] == "failed"
    assert journal["deviated"] is True
    assert len(journal["run"]) == 2