-
Notifications
You must be signed in to change notification settings - Fork 90
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
Setup integration tests #619
base: main
Are you sure you want to change the base?
Setup integration tests #619
Conversation
Without this we can't create a token configuration from outside the crate. Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
Looks great! One question before getting into the code: why not we directly have an A quick glance is that way we need to add This way, we could avoid another sub crate. |
I think this would work. I see the integration tests as having a broader scope than just the KBS, so I made a new package, but if that adds overhead I could move it. Generally I think that since the repo merge, we've had some stuff in individual packages that should really be in the top of the repo (like configs and docs, perhaps). |
1adf56a
to
b311ab0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to have a separate crate if we want to add more tests. One question is that we are having some e2e test
- docker-compose ci
- e2e test here
- this PR
Do we need to delete some duplicated ones?
allow = false | ||
"; | ||
|
||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this lint macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Custom
and DenyAll
variants are never instantiated. I could move the dead code thing just to those variants but then I'd have to use it twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we comment them out if they just have informational value?
b311ab0
to
5d3767a
Compare
Since these integration tests use the crate directly, they don't test the binaries or the docker-compose configuration or the k8s configuration. I think it's fine to keep some simple tests around that make sure that those interfaces still work. We should do a little bit of cleanup and organization with our existing tests, but I think that's for another PR. |
669f8e6
to
75dee21
Compare
The existing serve function returns a future that must be awaited on for the server to run. This causes the caller to block and does not allow the server to be halted unless the process is terminated. This is not ideal when using the server as a crate (or in a test). Instead, add a function that returns a server which can then be awaited on or run in the background. Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
To support integration tests written in rust, let's add a new package (which will only be used internally) called integration-tests. Inside the package, we have a tests repo where we can put tests. The package imports other trustee packages using a local path, so it should always have the most recent version of things. Now integration tests will run simply by doing cargo test at the top of the repo. Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
Let the make check target (which maybe should be renamed?) also run the integration tests. Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
89754d0
to
fb4069f
Compare
The OPA linter seems to have updated and now complains if we don't use an if before our blocks. This is unrelated to the rest of this PR. Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
fb4069f
to
ce92336
Compare
@@ -28,10 +28,11 @@ | |||
package policy | |||
|
|||
import future.keywords.every | |||
import future.keywords.if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's going on here? was if
not in the original simple-default-policy and should have been (so you added it)?
allow = false | ||
"; | ||
|
||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we comment them out if they just have informational value?
@@ -81,7 +81,7 @@ uninstall: | |||
rm -rf $(INSTALL_DESTDIR)/kbs $(INSTALL_DESTDIR)/kbs-client $(INSTALL_DESTDIR)/issuer-kbs $(INSTALL_DESTDIR)/resource-kbs | |||
|
|||
check: | |||
cargo test -p kbs -p kbs-client | |||
cargo test -p kbs -p kbs-client -p integration-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will get hit here in our regular workflows, right? (If so, that's what we want, I think.)
Creates a framework for writing Trustee integration tests in Rust.
Put your tests in
integration-tests/tests/integration.rs
(or a similar file) and they will run when you docargo test
at the top level.I've added two simple integration tests. They aren't anything beyond what we already have in other tests, but they add a structure that should help us to create a lot more. Before I get too carried away, please take a look at the setup.
Note that running the KBS in the background was trickier than expected. I think I found a pretty good way to do it in the end.