Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add bootstrap fixture for bootstrap tests #8781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
27bcca6
Start to flesh out fixture
simonrw Jul 31, 2023
ad5b50b
Move container fixture to pytest conftest file
simonrw Jul 31, 2023
5e27284
Use updated LocalstackContainer
simonrw Jul 31, 2023
7c9e3d4
Don't expose ports by default
simonrw Jul 31, 2023
1b27437
Add test for GATEWAY_LISTEN
simonrw Jul 31, 2023
61de777
WIP: add runningcontainer type
simonrw Aug 1, 2023
c723693
Add running container abstraction
simonrw Aug 1, 2023
8577a42
Revert invalid automated refactor
simonrw Aug 1, 2023
5ca588c
Do not pass detach - this is not part of the create API
simonrw Aug 2, 2023
c7a0496
More robust container logs test
simonrw Aug 10, 2023
413ac3b
Add attach_to_container method in docker client
simonrw Aug 18, 2023
998cf8b
Configure ContainerConfiguration rather than container
simonrw Aug 21, 2023
e02633c
Handle logfile outside of LocalstackContainer
simonrw Aug 21, 2023
c6cad7b
Don't use relative imports
simonrw Aug 23, 2023
7c2efe6
Fix not printing to the terminal correctly
simonrw Aug 23, 2023
c9d5f6a
Remove outdated comment
simonrw Aug 23, 2023
0a41ffc
Put back wrongly removed additional_flags
simonrw Aug 23, 2023
de2744a
Move cleanups fixture to common location
simonrw Aug 23, 2023
db3da41
Fix additional flag usage
simonrw Aug 23, 2023
f05af93
Swap match blocks for isinstance checks
simonrw Aug 24, 2023
763e987
Revert "Move cleanups fixture to common location"
simonrw Aug 24, 2023
39bf30d
Allow localstack.testing.pytest.fixtures in bootstrap tests
simonrw Aug 24, 2023
64b8319
Revert "Allow localstack.testing.pytest.fixtures in bootstrap tests"
simonrw Aug 24, 2023
c9617c9
Duplicate cleanups fixture for now
simonrw Aug 24, 2023
02ffe32
Merge branch 'master' into bootstrap-fixture
simonrw Aug 29, 2023
cd70b64
Disable most test fixtures for bootstrap tests
simonrw Aug 29, 2023
64f0efa
Configuration utilities take container
simonrw Aug 29, 2023
7042c49
Rename truncate_log -> truncate_file
simonrw Aug 31, 2023
da9b620
Merge remote-tracking branch 'origin/master' into bootstrap-fixture
simonrw Aug 31, 2023
99b567c
Allow for custom docker client
simonrw Aug 31, 2023
6cf702a
Configuration runs on container not config
simonrw Aug 31, 2023
f53f0e4
Fix circleci bootstrap test invocation
simonrw Aug 31, 2023
505674d
Pass tinybird args flag on command line
simonrw Aug 31, 2023
effa04a
Reset circleci config
simonrw Aug 31, 2023
dbbf45b
Disable localstack.pytest.fixtures
simonrw Aug 31, 2023
65ea529
Handle health check better
simonrw Aug 31, 2023
06a03cb
Update localstack/utils/container_utils/docker_cmd_client.py
simonrw Aug 31, 2023
f341355
Handle shutdown type failures
simonrw Aug 31, 2023
9bc8ce1
Revert custom cleanups implementation
simonrw Aug 31, 2023
63adfbb
Remove localstack specifics from Container
simonrw Sep 1, 2023
2f9e306
Merge remote-tracking branch 'origin/master' into bootstrap-fixture
simonrw Sep 1, 2023
4dd1f91
Merge remote-tracking branch 'origin/master' into bootstrap-fixture
simonrw Sep 1, 2023
65f2281
Add timeout to poll_condition for wait_for_localstack_ready
simonrw Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ jobs:
TEST_PATH: "tests/bootstrap"
COVERAGE_ARGS: "-p"
command: |
PYTEST_ARGS="-s ${TINYBIRD_PYTEST_ARGS}--junitxml=target/reports/bootstrap-tests.xml -o junit_suite_name=bootstrap-tests" make test-coverage
PYTEST_ARGS="${TINYBIRD_PYTEST_ARGS}--junitxml=target/reports/bootstrap-tests.xml -o junit_suite_name=bootstrap-tests" make test-coverage
- store_test_results:
path: target/reports/
- run:
Expand Down
4 changes: 2 additions & 2 deletions localstack/cli/localstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from localstack import config
from localstack.utils.analytics.cli import publish_invocation
from localstack.utils.bootstrap import get_container_default_logfile_location
from localstack.utils.json import CustomEncoder

if sys.version_info >= (3, 8):
Expand Down Expand Up @@ -532,11 +533,10 @@ def cmd_logs(follow: bool, tail: int) -> None:
If your LocalStack container has a different name, set the config variable
`MAIN_CONTAINER_NAME`.
"""
from localstack.utils.bootstrap import LocalstackContainer
from localstack.utils.docker_utils import DOCKER_CLIENT

container_name = config.MAIN_CONTAINER_NAME
logfile = LocalstackContainer(container_name).logfile
logfile = get_container_default_logfile_location(container_name)

if not DOCKER_CLIENT.is_container_running(container_name):
console.print("localstack container not running")
Expand Down
5 changes: 3 additions & 2 deletions localstack/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

from localstack import config
from localstack.runtime import hooks
from localstack.utils.bootstrap import Container

LOG = logging.getLogger(__name__)


@hooks.configure_localstack_container()
def configure_edge_port(container):
def configure_edge_port(container: Container):
ports = [config.EDGE_PORT, config.EDGE_PORT_HTTP]
LOG.debug("configuring container with edge ports: %s", ports)
for port in ports:
if port:
container.ports.add(port)
container.config.ports.add(port)


# Register the ArnPartitionRewriteListener only if the feature flag is enabled
Expand Down
2 changes: 1 addition & 1 deletion localstack/testing/pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ def factory(ports=None, **kwargs):


@pytest.fixture
def cleanups(aws_client):
def cleanups():
cleanup_fns = []

yield cleanup_fns
Expand Down
5 changes: 3 additions & 2 deletions localstack/utils/analytics/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from localstack import config, constants
from localstack.runtime import hooks
from localstack.utils.bootstrap import Container
from localstack.utils.functions import call_safe
from localstack.utils.json import FileMappedDocument
from localstack.utils.objects import singleton_factory
Expand Down Expand Up @@ -177,12 +178,12 @@ def prepare_host_machine_id():


@hooks.configure_localstack_container()
def _mount_machine_file(container):
def _mount_machine_file(container: Container):
from localstack.utils.container_utils.container_client import VolumeBind

# mount tha machine file from the host's CLI cache directory into the appropriate location in the
# container
machine_file = os.path.join(config.dirs.cache, "machine.json")
if os.path.isfile(machine_file):
target = os.path.join(config.dirs.for_container().cache, "machine.json")
container.volumes.add(VolumeBind(machine_file, target, read_only=True))
container.config.volumes.add(VolumeBind(machine_file, target, read_only=True))
Loading