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

Extend test matrix to cover more possible build combinations of features #122

Merged
merged 19 commits into from
Dec 10, 2024

Conversation

Jakuje
Copy link
Contributor

@Jakuje Jakuje commented Nov 28, 2024

With the amount of features the kryoptic supports, keeping track that they are self contained and all of the dependencies is quite tedious work.

This extends the test matrix and updates the tests to be able to run with different storages. For now, jsondb, sqlitedb and nssdb work, but the memorydb does not. Additionally, I encountered the issue that the memory db is not possible to provision, unless encryption is turned on, because it tries to find PIN counters, which are not in non-encrypted storage.

Fixes: #118

@Jakuje Jakuje force-pushed the test-matrix branch 3 times, most recently from b96c62d to af4d8b1 Compare November 29, 2024 18:45
@Jakuje
Copy link
Contributor Author

Jakuje commented Nov 29, 2024

This is mostly ready for review. The only thing to figure out is the issue with the memorydb and why the jsondb fails in CI, but works locally.
If needed, changes can be merged and CI changes could land later after we will figure out last details.

@Jakuje Jakuje marked this pull request as ready for review November 29, 2024 18:51
@Jakuje Jakuje requested a review from simo5 November 29, 2024 18:51
Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

Looks largely ok, only minor nits.
Thanks this is exactly where I wanted to see things headed!

src/config.rs Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
src/tests/mod.rs Outdated Show resolved Hide resolved
src/tests/mod.rs Outdated Show resolved Hide resolved
src/tests/objects.rs Show resolved Hide resolved
src/tests/aes.rs Show resolved Hide resolved
src/tests/init.rs Outdated Show resolved Hide resolved
src/tests/login.rs Outdated Show resolved Hide resolved
src/tests/nssdb.rs Outdated Show resolved Hide resolved
@tomato42
Copy link
Collaborator

tomato42 commented Dec 1, 2024

The idea is to be comprehensive in the coverage, or just have at least some test coverage?

because I has some experience with all-pairs testing and extension of it to triplets, quadruplets, etc....

@Jakuje
Copy link
Contributor Author

Jakuje commented Dec 1, 2024

The idea is to be comprehensive in the coverage, or just have at least some test coverage?

because I has some experience with all-pairs testing and extension of it to triplets, quadruplets, etc....

Right now, we have around 25 features:

https://github.com/latchset/kryoptic/blob/main/Cargo.toml#L49

They have some internal dependencies and then there is the "default" feature which we want or dont want to build. I was worried that doing all pairs (or triplets) would explode or would be even more work to exclude meaningless ones.

@tomato42
Copy link
Collaborator

tomato42 commented Dec 1, 2024

The idea is to be comprehensive in the coverage, or just have at least some test coverage?
because I has some experience with all-pairs testing and extension of it to triplets, quadruplets, etc....

Right now, we have around 25 features:

https://github.com/latchset/kryoptic/blob/main/Cargo.toml#L49

They have some internal dependencies and then there is the "default" feature which we want or dont want to build. I was worried that doing all pairs (or triplets) would explode or would be even more work to exclude meaningless ones.

all pairs (n-tuples) testing is especially effective if you have a lot of features, as then you avoid the combinatorial explosion

and no, having meaningless combinations is not a problem, when you generate the combinations you can exclude combinations that are either impossible to support (like testing ECDH on build without ECC) or combinations we explicitly don't want to support (for whatever reason)

@simo5
Copy link
Member

simo5 commented Dec 2, 2024

The idea is to be comprehensive in the coverage, or just have at least some test coverage?
because I has some experience with all-pairs testing and extension of it to triplets, quadruplets, etc....

Right now, we have around 25 features:
https://github.com/latchset/kryoptic/blob/main/Cargo.toml#L49
They have some internal dependencies and then there is the "default" feature which we want or dont want to build. I was worried that doing all pairs (or triplets) would explode or would be even more work to exclude meaningless ones.

all pairs (n-tuples) testing is especially effective if you have a lot of features, as then you avoid the combinatorial explosion

and no, having meaningless combinations is not a problem, when you generate the combinations you can exclude combinations that are either impossible to support (like testing ECDH on build without ECC) or combinations we explicitly don't want to support (for whatever reason)

In most cases each algorithm is fully independent from each other algorithm, so that testing them in pairs makes little sense.

We have a core that is always involved and therefore is always tested.

Then we have the algorithms which just operate on specific data, regardless of the core or anything else.

The only major variability is the databases, because what they contain may influence the result of specific tests.

So perhaps testing each "true leaf" algorithm on their own with each database may make some sense. Mostly to ensure there is no unexpected dependency between algorithms, but that is rather simple to verify so I would not want to spend a lot of CPU on that, and definitely not make CI much slower due to this.

Perhaps we can have matrix testing done once a week on a scheduled CI run just for completeness.

@Jakuje
Copy link
Contributor Author

Jakuje commented Dec 9, 2024

warning: method dbsuffix is never used

With recent changes the dbsuffix is not used anywhere. I kept it for now because it might be useful in the future, even though it works only for SQL and JSON. If you do not agree, I can remove it altogether.

@Jakuje Jakuje force-pushed the test-matrix branch 3 times, most recently from 7c6b9c4 to 4cd093e Compare December 9, 2024 13:27
@simo5
Copy link
Member

simo5 commented Dec 9, 2024

warning: method dbsuffix is never used

With recent changes the dbsuffix is not used anywhere. I kept it for now because it might be useful in the future, even though it works only for SQL and JSON. If you do not agree, I can remove it altogether.

We can always resurrect from git, I am ok dropping anything that is not used anymore.

Jakuje added 10 commits December 9, 2024 21:11
Signed-off-by: Jakub Jelen <[email protected]>
This does not work with the NSS DB. Use more common reference
by ID and class.

Signed-off-by: Jakub Jelen <[email protected]>
Signed-off-by: Jakub Jelen <[email protected]>
The name dbpath is confusing as it is a path only for 2 dbs for now.
For memory, there are optional arguments, as there is really no path
and for NSS DB, the directory needs to be prefixed with `configDir=`,
which makes it very nonintuitive.

Signed-off-by: Jakub Jelen <[email protected]>
Signed-off-by: Jakub Jelen <[email protected]>
move what makes sense to RSA test.

Signed-off-by: Jakub Jelen <[email protected]>
The test drivers are now written for persistent storage to properly
excercise the whole process from library initialization, reading
data from persistent storage, writing them and more.

The memorydb is specific as it is not persistent. In the tests,
we are able to initialize it successfully, but the content is thrown
away and then a new empty token is created again, which does not
have the expected content.

Signed-off-by: Jakub Jelen <[email protected]>
Copy link
Member

@simo5 simo5 left a comment

Choose a reason for hiding this comment

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

Only a couple of nits, but great job with this, thanks!!

src/tests/init.rs Show resolved Hide resolved
src/tests/mod.rs Show resolved Hide resolved
src/tests/objects.rs Show resolved Hide resolved
@simo5 simo5 merged commit 951bd54 into latchset:main Dec 10, 2024
19 checks passed
@simo5
Copy link
Member

simo5 commented Dec 10, 2024

Thanks for this work, really appreciated!

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.

Extend test coverage matrix
3 participants