예제 #1
0
def test_history_server_run(mock_subprocess_popen,
                            mock_get_run_history_server_cmd, mock_down):
    mock_get_run_history_server_cmd.return_value = (
        "docker run --env AWS_ACCESS_KEY_ID=123 "
        "--name history_server --network host --entrypoint "
        "smspark-history-server image_uri")
    history_server = _HistoryServer({}, "image_uri", "--network host")

    history_server.run()

    mock_down.assert_called_once()
    mock_subprocess_popen.assert_called_with(
        [
            "docker",
            "run",
            "--env",
            "AWS_ACCESS_KEY_ID=123",
            "--name",
            "history_server",
            "--network",
            "host",
            "--entrypoint",
            "smspark-history-server",
            "image_uri",
        ],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
예제 #2
0
def test_history_server_down(mock_subprocess_call):
    history_server = _HistoryServer({}, "image_uri", "--network host")

    history_server.down()

    mock_subprocess_call.assert_has_calls([
        call(["docker", "stop", "history_server"]),
        call(["docker", "rm", "history_server"])
    ])
예제 #3
0
def test_get_run_history_server_cmd():
    args = {
        "AWS_ACCESS_KEY_ID": "123",
        "AWS_SECRET_ACCESS_KEY": "456",
        "AWS_SESSION_TOKEN": "789",
        "event_logs_s3_uri": "s3://bucket",
        "remote_domain_name": "domain",
    }

    history_server = _HistoryServer(args, "image_uri", "--network host")
    result = history_server._get_run_history_server_cmd()
    expected_cmd = (
        "docker run --env AWS_ACCESS_KEY_ID=123 --env AWS_SECRET_ACCESS_KEY=456 "
        "--env AWS_SESSION_TOKEN=789 --name history_server --network host --entrypoint "
        "smspark-history-server image_uri --event-logs-s3-uri s3://bucket --remote-domain-name domain"
    )

    assert result == expected_cmd