localstack/localstack-java-utils

Unknown port mapping for service: sqs

mmartinsky opened this issue · 1 comments

Version: 0.2.7
OS: MacOS Catalina

Cloned a repo with LocalStack related SQS tests, but seeing issues with the below test:

@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(services = {"sqs"})
@EnabledOnOs({OS.MAC})
public class SqsStreamClientTest {

    @Test
    public void it_should_get_queue_url() throws ExecutionException, InterruptedException {
        //Arrange
        SqsAsyncClient sqsAsyncClient = TestUtils.getClientSQSAsyncV2();
        String queueName = "test-queue";
        sqsAsyncClient.createQueue(CreateQueueRequest.builder().queueName(queueName).build()).get();
        SqsStreamClient target = new SqsStreamClient(sqsAsyncClient);

        //Act
        String queueUrl = target.getQueueUrl(queueName, sqsAsyncClient);

        //Assert
        assertEquals("http://localhost:4566/000000000000/test-queue", queueUrl);
    }
}

Error:

Unknown port mapping for service: sqs
java.lang.IllegalArgumentException: Unknown port mapping for service: sqs
	at cloud.localstack.Localstack.getServicePort(Localstack.java:223)
	at cloud.localstack.Localstack.endpointForService(Localstack.java:214)
	at cloud.localstack.Localstack.getEndpointSQS(Localstack.java:166)
	at cloud.localstack.awssdkv2.TestUtils.getClientSQSAsyncV2(TestUtils.java:38)
	at com.trp.dit.lux.core.infrastructure.SqsStreamClientTest.it_should_get_queue_url(SqsStreamClientTest.java:24)
       ....

Debugging into

private void loadServiceToPortMap() {
        String localStackPortConfig = localStackContainer.executeCommand(Arrays.asList("cat", PORT_CONFIG_FILENAME));

        int edgePort = getEdgePort();
        Map<String, Integer> ports = new RegexStream(DEFAULT_PORT_PATTERN.matcher(localStackPortConfig)).stream()
                .collect(Collectors.toMap(match -> match.group(1), match -> edgePort));

        serviceToPortMap = Collections.unmodifiableMap(ports);
    }

localStackPortConfig = 'cat: can't open '/opt/code/localstack/.venv/lib/python3.8/site-packages/localstack_client/config.py': No such file or directory'

When I run localStackContainer.executeCommand(Arrays.asList("ls", "/opt/code/localstack/.venv/lib")), I see "python3.7" returned - how should I fix this mismatching version?

It seems related to localstack/localstack#2082.

Solved by upgrading version to 0.2.14