Skip to content
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

NH-53257 Use docker instead of compose to run test containers #50

Merged
merged 5 commits into from
Aug 4, 2023

Conversation

cheempz
Copy link
Contributor

@cheempz cheempz commented Aug 3, 2023

https://swicloud.atlassian.net/browse/NH-53257

Use docker to run test containers. This is to address the problem that with the original compose-based way, it's not possible to run multiple containers via the rake tasks because each docker_dev and docker_tests task invocation will tear the entire compose stack down. I thought about using compose profiles or separate compose files, but just using plain docker run seemed the simplest given current use case. Also stop setting a name for the test containers since that could cause run failure due to name collision, and seemed not needed for these disposable containers.

  • pros: can run any official docker ruby image, for example quickly test against upcoming ruby versions.
  • cons: compose-based run would allow launching multiple test containers in parallel, or adding supporting containers like db, cache, etc.

Fix the otel_config_propagator_test.rb failures by requiring solarwinds_apm/config and setting a dummy service key. This issue was seen when running just this single test file, we should probably improve the test setup/teardown so that there aren't these masked dependencies.

No longer need to set global bundler config, since official ruby containers use the BUNDLE_APP_CONFIG env var which bypasses collisions between config set on the host machine and set within the container. So added it along with BUNDLE_SILENCE_ROOT_WARNING to the dev container.

Fix otel_config_propagator_test.rb failures by requiring dependency and setting a dummy service key
@cheempz cheempz requested a review from a team August 3, 2023 04:48
test/minitest_helper.rb Fixed Show fixed Hide fixed
@cheempz cheempz changed the title Use docker instead of compose to run test containers; NH-53257 Use docker instead of compose to run test containers Aug 3, 2023
xuan-cao-swi
xuan-cao-swi previously approved these changes Aug 3, 2023
Rakefile Outdated
Comment on lines 49 to 51
--volume $PWD:/code/ruby-solarwinds --workdir /code/ruby-solarwinds \
--entrypoint test/test_setup.sh -e RUN_TESTS=1 \
--name ruby_sw_apm_#{args.os}_#{args.ruby_version} ruby_sw_apm_#{args.os}_#{args.ruby_version}"
--name ruby_sw_apm_#{args.tag} ruby:#{args.tag}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have choice of platform like

cmd = "docker run --rm --tty \
    --volume $PWD:/code/ruby-solarwinds --workdir /code/ruby-solarwinds \
    --entrypoint test/test_setup.sh -e RUN_TESTS=1 --platform=#{args.platform} \
    --name ruby_sw_apm_#{args.tag} ruby:#{args.tag}"

but please ignore if too much arguments for rake task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, to allow running tests on alpine :). Added!

Remove test container name clash
@cheempz
Copy link
Contributor Author

cheempz commented Aug 3, 2023

Pushed 525df31 because I ran into an issue setting up VSCode Ruby LSP extension (pretty cool, recommend it) which boiled down to the global bundle "without" config that interfered with the extension's gem installation. Looking more, found we can actually set the config at local level and take advantage of the environment vars set in official ruby containers, as noted in the updated PR description.

Copy link
Contributor

@xuan-cao-swi xuan-cao-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cheempz cheempz merged commit 578a1a2 into main Aug 4, 2023
12 checks passed
@cheempz cheempz deleted the separate-test-dev branch August 4, 2023 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants