Пример #1
0
def run_localstack():
    """
    Start localstack and block until it terminates. Terminate localstack by calling _trigger_stop().
    """
    # configure
    os.environ[ENV_INTERNAL_TEST_RUN] = "1"
    safe_requests.verify_ssl = False
    config.FORCE_SHUTDOWN = False
    config.EDGE_BIND_HOST = "0.0.0.0"

    def watchdog():
        logger.info("waiting stop event")
        localstack_stop.wait()  # triggered by _trigger_stop()
        logger.info("stopping infra")
        infra.stop_infra()

    def start_profiling(*args):
        if not config.USE_PROFILER:
            return

        @profiled()
        def profile_func():
            # keep profiler active until tests have finished
            localstack_stopped.wait()

        print("Start profiling...")
        profile_func()
        print("Done profiling...")

    monitor = threading.Thread(target=watchdog)
    monitor.start()

    logger.info("starting localstack infrastructure")
    infra.start_infra(asynchronous=True)

    threading.Thread(target=start_profiling).start()

    for fn in test_init_functions:
        try:
            # asynchronous init functions
            fn()
        except Exception:
            logger.exception("exception while running init function for test")

    logger.info("waiting for infra to be ready")
    infra.INFRA_READY.wait()  # wait for infra to start (threading event)
    localstack_started.set()  # set conftest inter-process Event

    logger.info("waiting for shutdown")
    try:
        logger.info("waiting for watchdog to join")
        monitor.join()
    finally:
        logger.info("ok bye")
        localstack_stopped.set()
def setup_package():
    try:
        os.environ[ENV_INTERNAL_TEST_RUN] = '1'
        # disable SSL verification for local tests
        safe_requests.verify_ssl = False
        # start infrastructure services
        infra.start_infra(asynchronous=True)
    except Exception as e:
        # make sure to tear down the infrastructure
        infra.stop_infra()
        raise e
Пример #3
0
def localstack():
    from localstack.services import infra
    infra.start_infra(
        asynchronous=True,
        apis=[
            'ses', 'lambda', 'sqs', 'dynamodb',
            'cloudwatch',  # required for lambda to work
        ],
    )
    yield
    infra.stop_infra()
Пример #4
0
def setup_package():
    try:
        os.environ[ENV_INTERNAL_TEST_RUN] = '1'
        # disable SSL verification for local tests
        safe_requests.verify_ssl = False
        # start infrastructure services
        infra.start_infra(async=True)
    except Exception as e:
        # make sure to tear down the infrastructure
        infra.stop_infra()
        raise e
Пример #5
0
def run_localstack():
    """
    Start localstack and block until it terminates. Terminate localstack by calling _trigger_stop().
    """
    # configure
    os.environ[ENV_INTERNAL_TEST_RUN] = '1'
    safe_requests.verify_ssl = False
    config.FORCE_SHUTDOWN = False
    config.EDGE_BIND_HOST = '0.0.0.0'

    def watchdog():
        logger.info('waiting stop event')
        localstack_stop.wait()  # triggered by _trigger_stop()
        logger.info('stopping infra')
        infra.stop_infra()

    def start_profiling(*args):
        if not config.USE_PROFILER:
            return

        @profiled()
        def profile_func():
            # keep profiler active until tests have finished
            localstack_stopped.wait()

        print('Start profiling...')
        profile_func()
        print('Done profiling...')

    monitor = threading.Thread(target=watchdog)
    monitor.start()

    logger.info('starting localstack infrastructure')
    infra.start_infra(asynchronous=True)

    threading.Thread(target=start_profiling).start()

    if will_run_terraform_tests.is_set():
        logger.info('running terraform init')
        # init terraform binary if necessary
        TestTerraform.init_async()

    logger.info('waiting for infra to be ready')
    infra.INFRA_READY.wait()  # wait for infra to start (threading event)
    localstack_started.set()  # set conftest inter-process Event

    logger.info('waiting for shutdown')
    try:
        logger.info('waiting for watchdog to join')
        monitor.join()
    finally:
        logger.info('ok bye')
        localstack_stopped.set()
Пример #6
0
def setup_package():
    try:
        os.environ[ENV_INTERNAL_TEST_RUN] = '1'
        # disable SSL verification for local tests
        safe_requests.verify_ssl = False
        # start profiling
        FuncThread(start_profiling).start()
        # start infrastructure services
        infra.start_infra(asynchronous=True)
        # initializing terraform
        TestTerraform.init_async()
    except Exception as e:
        # make sure to tear down the infrastructure
        infra.stop_infra()
        raise e
Пример #7
0
def setup_package():
    try:
        os.environ[ENV_INTERNAL_TEST_RUN] = '1'
        # disable SSL verification for local tests
        safe_requests.verify_ssl = False
        # start profiling
        FuncThread(start_profiling).start()
        # start infrastructure services
        infra.start_infra(asynchronous=True)
        # initialize certain tests asynchronously to reduce overall test time
        if not os.environ.get('TEST_PATH') or 'terraform' in os.environ.get(
                'TEST_PATH'):
            TestTerraform.init_async()
    except Exception as e:
        # make sure to tear down the infrastructure
        infra.stop_infra()
        raise e
Пример #8
0
def run_localstack():
    """
    Start localstack and block until it terminates. Terminate localstack by calling _trigger_stop().
    """
    # configure
    os.environ[ENV_INTERNAL_TEST_RUN] = "1"
    safe_requests.verify_ssl = False
    config.FORCE_SHUTDOWN = False
    config.EDGE_BIND_HOST = "0.0.0.0"

    def watchdog():
        logger.info("waiting stop event")
        localstack_stop.wait()  # triggered by _trigger_stop()
        logger.info("stopping infra")
        infra.stop_infra()

    monitor = threading.Thread(target=watchdog)
    monitor.start()

    logger.info("starting localstack infrastructure")
    infra.start_infra(asynchronous=True)

    for fn in test_init_functions:
        try:
            # asynchronous init functions
            fn()
        except Exception:
            logger.exception("exception while running init function for test")

    logger.info("waiting for infra to be ready")
    events.infra_ready.wait()  # wait for infra to start (threading event)
    localstack_started.set()  # set conftest inter-process Event

    logger.info("waiting for shutdown")
    try:
        logger.info("waiting for watchdog to join")
        monitor.join()
    finally:
        logger.info("ok bye")
        localstack_stopped.set()
Пример #9
0
def cmd_infra(argv, args):
    """
Usage:
  localstack infra <subcommand> [options]

Commands:
  infra start         Start the local infrastructure

Options:
  --docker            Run the infrastructure in a Docker container
    """
    if argv[0] == 'start':
        argv = ['infra', 'start'] + argv[1:]
        args['<command>'] = 'infra'
        args['<args>'] = ['start'] + args['<args>']
    args.update(docopt(cmd_infra.__doc__.strip(), argv=argv))
    if args['<subcommand>'] == 'start':
        print('Starting local dev environment. CTRL-C to quit.')
        if args['--docker']:
            infra.start_infra_in_docker()
        else:
            infra.start_infra()
Пример #10
0
def start_infra_locally():
    bootstrap_installation()
    from localstack.services import infra
    return infra.start_infra()
Пример #11
0
 def setUpClass(cls):
     infra.start_infra(asynchronous=True, apis=('s3', 'kinesis'))
Пример #12
0
def start_infra_locally():
    from localstack.services import infra

    return infra.start_infra()
Пример #13
0
 def setup_class(cls):
     infra.start_infra(asynchronous=True, apis=["s3"])
     boto3.DEFAULT_SESSION = LocalS3Session()
     cls.s3_client = boto3.client("s3")
     cls.s3_resource = boto3.resource("s3")
Пример #14
0
 def setup_class(self):
     infra.start_infra(asynchronous=True, apis=["s3"])
     boto3.DEFAULT_SESSION = LocalS3Session()
     self.s3_client = boto3.client('s3')
     self.s3_resource = boto3.resource('s3')
Пример #15
0
 def setUp(self):
     # Start localstack
     infra.start_infra(apis=['lambda', 'iam', 'cloudwatch'], asynchronous=True)
     self.set_tf_var()
     terraform_helper.terraform_start()