How to use build_cluster_endpoint method in localstack

Best Python code snippet using localstack_python

test_cluster_manager.py

Source:test_cluster_manager.py Github

copy

Full Screen

...5from localstack.services.opensearch.cluster_manager import DomainKey, build_cluster_endpoint6class TestBuildClusterEndpoint:7 def test_endpoint_strategy_port(self, monkeypatch):8 monkeypatch.setattr(config, "OPENSEARCH_ENDPOINT_STRATEGY", "port")9 endpoint = build_cluster_endpoint(DomainKey("my-domain", "us-east-1", TEST_AWS_ACCOUNT_ID))10 parts = endpoint.split(":")11 assert parts[0] == "localhost"12 assert int(parts[1]) in range(13 config.EXTERNAL_SERVICE_PORTS_START, config.EXTERNAL_SERVICE_PORTS_END14 )15 @pytest.mark.skipif(16 condition=config.in_docker(), reason="port mapping differs when being run in the container"17 )18 @pytest.mark.parametrize(19 "engine", [(EngineType.OpenSearch, "opensearch"), (EngineType.Elasticsearch, "es")]20 )21 def test_endpoint_strategy_path(self, monkeypatch, engine):22 monkeypatch.setattr(config, "OPENSEARCH_ENDPOINT_STRATEGY", "path")23 engine_type = engine[0]24 engine_path_prefix = engine[1]25 endpoint = build_cluster_endpoint(26 DomainKey("my-domain", "us-east-1", TEST_AWS_ACCOUNT_ID), engine_type=engine_type27 )28 assert endpoint == f"localhost:4566/{engine_path_prefix}/us-east-1/my-domain"29 endpoint = build_cluster_endpoint(30 DomainKey("my-domain-1", "eu-central-1", TEST_AWS_ACCOUNT_ID), engine_type=engine_type31 )32 assert endpoint == f"localhost:4566/{engine_path_prefix}/eu-central-1/my-domain-1"33 @pytest.mark.skipif(34 condition=config.in_docker(), reason="port mapping differs when being run in the container"35 )36 @pytest.mark.parametrize(37 "engine", [(EngineType.OpenSearch, "opensearch"), (EngineType.Elasticsearch, "es")]38 )39 def test_endpoint_strategy_domain(self, monkeypatch, engine):40 monkeypatch.setattr(config, "OPENSEARCH_ENDPOINT_STRATEGY", "domain")41 engine_type = engine[0]42 engine_path_prefix = engine[1]43 endpoint = build_cluster_endpoint(44 domain_key=DomainKey("my-domain", "us-east-1", TEST_AWS_ACCOUNT_ID),45 engine_type=engine_type,46 )47 assert (48 endpoint == f"my-domain.us-east-1.{engine_path_prefix}.localhost.localstack.cloud:4566"49 )50 endpoint = build_cluster_endpoint(51 domain_key=DomainKey("my-domain-1", "eu-central-1", TEST_AWS_ACCOUNT_ID),52 engine_type=engine_type,53 )54 assert (55 endpoint56 == f"my-domain-1.eu-central-1.{engine_path_prefix}.localhost.localstack.cloud:4566"57 )58class TestDomainKey:59 def test_from_arn(self):60 domain_key = DomainKey.from_arn("arn:aws:es:us-east-1:012345678901:domain/my-es-domain")61 assert domain_key.domain_name == "my-es-domain"62 assert domain_key.region == "us-east-1"63 assert domain_key.account == "012345678901"64 def test_arn(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful