Exemple #1
0
def test_hydra_docker_cluster_start(mocker, random_str):
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_network.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_redis.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_api_server.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_load_balancer.__name__)

    clstr = HydraDockerCluster(random_str())

    clstr.start()

    clstr._start_network.assert_called_once()
    clstr._start_redis.assert_called_once()
    clstr._start_api_server.assert_called_once()
    clstr._start_load_balancer.assert_called_once()
Exemple #2
0
def test_hydra_docker_cluster_start_fail_raises(mocker, random_str):
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_network.__name__,
                        side_effect=Exception('Network exists!'))
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_redis.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_api_server.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster._start_load_balancer.__name__)
    mocker.patch.object(HydraDockerCluster,
                        HydraDockerCluster.destroy.__name__)

    clstr = HydraDockerCluster(random_str())

    with pytest.raises(ClusterError):
        clstr.start()

    clstr.destroy.assert_called_once()