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

Isolated integration tests #149

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lupine
Copy link
Contributor

@lupine lupine commented Mar 18, 2023

Don't mind me, just trying to get the integration tests working according to #147 (comment)

With the isolated approach, they're currently taking ~45 seconds to run locally, factoring out the cargo build part.

@lupine lupine force-pushed the nt-isolated-integration-tests branch 5 times, most recently from 63721db to 254a7f9 Compare March 18, 2023 22:44
@celsworth
Copy link
Owner

❤️

Haven't forgotten about the other PRs, just starting a new job so focused elsewhere at the moment :) Will take a look when I can. This looks awesome though, getting these running in CI was a good next step before expanding them to cover more cases, nice job :)

@lupine lupine force-pushed the nt-isolated-integration-tests branch from 254a7f9 to c808c43 Compare March 18, 2023 22:47
@lupine
Copy link
Contributor Author

lupine commented Mar 18, 2023

No worries; I'm just fiddling as I have time 😅 . The PR only exists at the moment because it's required to get the CI running.

Best of luck with the new job!

@lupine lupine force-pushed the nt-isolated-integration-tests branch 5 times, most recently from 5c0dd89 to 0b9bb24 Compare March 18, 2023 23:32
uses: actions-rs/cargo@v1
with:
command: test
args: --features=mocks

- name: Start Mosquitto
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really sure why the docker run approach isn't working inside github actions, and it's painful to debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is fine; it's like sharing a postgres database, which is common in tests.

It's occurred to me that I could achieve multitenancy (and even test parallelisation) by applying a custom MQTT prefix (i.e. topics would be lxp_test_XXXX/...) in lxp-bridge's config. Will look into that.

serial: 5555555555
datalog: 2222222222
heartbeats: true
# FIXME: get the specs passing with this enabled
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't actually in master yet.

Since we're now running an lxp-bridge per spec, we can vary the config-file per spec, rather than having it hardcoded. That's a few revisions away though.

@@ -1,27 +0,0 @@
#! /usr/bin/env ruby
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found it a lot easier to have this TCP server be inside the rspec process, so there isn't a process boundary to navigate. I think it would have been necessary for it to be a docker image before to get around weird networking sadness.

@@ -180,8 +180,6 @@
end # }}}

context 'receiving all unprompted input registers' do # {{{
before { sleep 0.2 } # avoid test seeing a row write from a previous test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can no longer happen \o/


# Set up an lxp-bridge instance
config.before(:suite) do
Kernel.system(*%w[cargo build --manifest-path ../Cargo.toml])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally we'd run the integration test after the build step and have it use the produced binary, rather than needing all of rust to run the ruby integration suite.

Copy link
Owner

Choose a reason for hiding this comment

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

I am tempted to drop the build steps from CI that build native binaries, at least for PRs, and instead build a Docker image. Then we can use that for the integration tests?

The native builds are a bit of a relic from pre-docker days and I doubt anyone uses them to be honest. Could keep the binaries builds for releases as thats completely separate CI anyway but even then I think we should encourage Docker-only use.

Copy link
Contributor Author

@lupine lupine Mar 19, 2023

Choose a reason for hiding this comment

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

In this PR, I'm starting a new lxp-bridge instance per test. I was starting a new mosquitto per test, using docker, but that's weirdly broken inside CI, so I've stopped: #149 (comment) . I expect an lxp-bridge docker container would have the same issue.

A docker image would just be the same binary sat inside a squashfs archive, with a few other gubbins; I wouldn't use docker for running lxp-bridge myself (I run on quite constrained hardware; it doesn't even have docker installed), but I don't much mind how CI works - as long as it does work 😅.

@lupine
Copy link
Contributor Author

lupine commented Mar 18, 2023

It's green \o/

config.before(:suite) do
RSpec.configuration.mqtt = MQTT::Client.connect('mqtt://localhost')
end
# Set up an MQTT server
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These blocks should really go into files in spec/support

@lupine lupine force-pushed the nt-isolated-integration-tests branch from 0b9bb24 to 7876fea Compare March 27, 2023 09:06
@celsworth celsworth force-pushed the master branch 2 times, most recently from d41335a to 6043637 Compare October 17, 2023 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants