localstack icon indicating copy to clipboard operation
localstack copied to clipboard

Cannot run Localstack unit tests in gitlab. Gitlab does not instantiate the appropriate docker infrastructure to accommodate the containers needed to run the unit tests.

Open steowens opened this issue 4 years ago • 3 comments

Type of request: This is a ...

[ ] bug report [ ] feature request [*] blocking usability issue

Detailed description

I am able to use the Localstack on unit tests when executing maven install on my laptop. However I would like those same unit tests to execute on a gitlab CICD pipeline. I have yet to find an example of any gitlab-ci.yml file which will actually allow this to happen. To make these tests work on a cicd runner docker has to run and maven has to run all in a Kubernetes pod.

Doesn't seem like anyone has this figured out. ...

Expected behavior

If you run maven install on the command line, and everything works, local stack starts a docker container executes your tests and exits with success, then the same thing should happen when you check your code into gitlab and the same tests run in the gitlab cicd pipeline ...

Actual behavior

The build fails usually because Localstack does not start in the cicd container. It can fail in other ways depending on how desperate you have gotten trying different things in your gitlab-ci.yml file to fix the issue. ...

Steps to reproduce

Command used to start LocalStack

Create a project that uses local stack with a unit test like so:

@ExtendWith(LocalstackDockerExtension.class) @LocalstackDockerProperties(portEdge = "4666", portElasticSearch = "4572", useSingleDockerContainer = true, services = { "dynamodb" }) @TestMethodOrder(OrderAnnotation.class) @TestInstance(Lifecycle.PER_CLASS) public class SomeKindaTest {...

Make sure you exercise AWS services and that your unit test builds on your machine with "mvn install"

Check things into gitlab and watch the world burn.

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

git push your code

steowens avatar Apr 09 '21 01:04 steowens

Thanks for reporting @steowens . Can you please share some details about your use case - ideally a small sample repo to allow us to reproduce this issue.

Which services are you using in your tests? In particular, Lambda functions can become a bit tricky to get working in CI environments (as the Lambda API is spawning new Docker containers to run the functions), but most of the other APIs should actually be relatively straight-forward to get running.

Please share details about your project, we'll be happy to look into it.. Thanks

whummer avatar Apr 10 '21 10:04 whummer

Ok so apparently I confused issues. The project I attached was for a different issue.I need to attach the above project to the right issue. You can close this issue. The problem still exists but the work around is don't enable Localstack unit tests in a gitlab runner, just run them on your laptop and disable them before checking the code in. But if you have an instance of gitlab, then you can easily reproduce this with any Localstack unit tests in Java on gitlab.

Deleting the above comments related to providing a demo project due to it not being related to this issue.

steowens avatar May 25 '21 17:05 steowens

Hello 👋! It looks like this issue hasn’t been active in longer than five months. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

localstack-bot avatar Nov 10 '22 17:11 localstack-bot