2022-01-03 00:44:03 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
import math
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import docker
|
|
|
|
import pytest
|
|
|
|
from docker.models.containers import Container
|
|
|
|
from helpers.cluster import ClickHouseCluster, get_docker_compose_path, run_and_check
|
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
DOCKER_COMPOSE_PATH = get_docker_compose_path()
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2022-03-22 16:39:58 +00:00
|
|
|
node = cluster.add_instance(
|
|
|
|
"node",
|
|
|
|
user_configs=["configs/users.xml"],
|
|
|
|
env_variables={"UBSAN_OPTIONS": "print_stacktrace=1"},
|
|
|
|
)
|
|
|
|
|
2022-01-03 00:44:03 +00:00
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
cluster.start()
|
|
|
|
try:
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
2022-03-22 16:39:58 +00:00
|
|
|
@pytest.fixture(scope="module")
|
2022-01-03 00:44:03 +00:00
|
|
|
def dotnet_container():
|
2022-03-22 16:39:58 +00:00
|
|
|
docker_compose = os.path.join(
|
|
|
|
DOCKER_COMPOSE_PATH, "docker_compose_dotnet_client.yml"
|
|
|
|
)
|
2022-01-03 00:44:03 +00:00
|
|
|
run_and_check(
|
2022-03-22 16:39:58 +00:00
|
|
|
[
|
|
|
|
"docker-compose",
|
|
|
|
"-p",
|
|
|
|
cluster.project_name,
|
|
|
|
"-f",
|
|
|
|
docker_compose,
|
|
|
|
"up",
|
2022-03-31 13:56:07 +00:00
|
|
|
"--force-recreate",
|
2022-03-22 16:39:58 +00:00
|
|
|
"-d",
|
|
|
|
"--no-build",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
yield docker.from_env().containers.get(cluster.project_name + "_dotnet1_1")
|
2022-01-03 00:44:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_dotnet_client(started_cluster, dotnet_container):
|
2022-03-22 16:39:58 +00:00
|
|
|
with open(os.path.join(SCRIPT_DIR, "dotnet.reference"), "rb") as fp:
|
2022-01-03 00:44:03 +00:00
|
|
|
reference = fp.read()
|
|
|
|
|
|
|
|
code, (stdout, stderr) = dotnet_container.exec_run(
|
2022-03-22 16:39:58 +00:00
|
|
|
"dotnet run --host {host} --port {port} --user default --password 123 --database default".format(
|
|
|
|
host=started_cluster.get_instance_ip("node"), port=8123
|
|
|
|
),
|
|
|
|
demux=True,
|
|
|
|
)
|
2022-01-03 00:44:03 +00:00
|
|
|
|
|
|
|
assert code == 0
|
|
|
|
assert stdout == reference
|