From b562141342f9204f4bc9bebdd6240633746f15fb Mon Sep 17 00:00:00 2001 From: Andrei <122784628+andrei-near@users.noreply.github.com> Date: Wed, 1 Feb 2023 11:04:03 +0000 Subject: [PATCH] Enabling network for neard localnet docker run --- pytest/tests/sanity/docker.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pytest/tests/sanity/docker.py b/pytest/tests/sanity/docker.py index a1513b2e353..cdf56e19d12 100644 --- a/pytest/tests/sanity/docker.py +++ b/pytest/tests/sanity/docker.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Verifies that node can be started inside of a Docker image. -The script builds Docker image using ‘make docker-nearcore’ command and then +The script builds Docker image using 'make docker-nearcore' command and then starts a cluster with all nodes running inside of containers. As sanity check to see if the cluster works correctly, the test waits for a several blocks and then interrogates each node about block with specified hash expecting all of @@ -48,7 +48,7 @@ def run(cmd: _Command, *, capture_output: bool = False) -> typing.Optional[str]: capture_output: If true, captures standard output of the command and returns it. Returns: - Command’s stripped standard output if `capture_output` is true, None + Command's stripped standard output if `capture_output` is true, None otherwise. """ global _CD_PRINTED @@ -73,7 +73,7 @@ def docker_run(shell_cmd: typing.Optional[str] = None, Args: shell_cmd: Optionally a shell command to execute inside of the - container. It’s going to be run using `sh -c` and it’s caller’s + container. It's going to be run using `sh -c` and it's caller's responsibility to make sure all data inside is properly sanitised. If not given, command configured via CMD when building the container will be executed as typical for Docker images. @@ -82,14 +82,14 @@ def docker_run(shell_cmd: typing.Optional[str] = None, test outputs. If True, the container will be detached and the function will return its container id. network: Whether to enable network. If True, the container will be - configured to use host’s network. This allows processes in + configured to use host's network. This allows processes in different containers to connect with each other easily. volume: A (path, container_path) tuple denoting that local `path` should be mounted under `container_path` inside of the container. env: *Additional* environment variables set inside of the container. Returns: - Command’s stripped standard output if `detach` is true, None otherwise. + Command's stripped standard output if `detach` is true, None otherwise. """ cmd = ['docker', 'run', '--read-only', f'-v{volume[0]}:{volume[1]}'] @@ -187,14 +187,14 @@ def output_logs(self): def main(): nodes = [] - # Build the container + logger.info("Build the container") run(('make', 'DOCKER_TAG=' + _DOCKER_IMAGE_TAG, 'docker-nearcore')) try: dot_near = pathlib.Path.home() / '.near' - # Initialise local network + logger.info("Initialise local network nodes config.") cmd = f'neard --home /home/near localnet --v {NUM_NODES} --prefix test' - docker_run(cmd, volume=(dot_near, '/home/near')) + docker_run(cmd, volume=(dot_near, '/home/near'), network=True) # Start all the nodes for ordinal in range(NUM_NODES):