Add Unit Tests for User Space Convertor #199
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR introduces tests for multiple functions in the user space convertor. This is meant to add to the long-term reliability and maintainability of the project. Part of #198
Please check the following list:
Notes:
As part of this change, I had to introduce registry mocking for resolve/push/fetch functionality, as a part of this I added the ORAS library which has a nice library to use for the in-storage implementation. I also added a few Manifests and layers as part of this. Tried to keep it minimal as this is checked in. Let me know if there are any concerns. Also, I am not the best with Unit tests so any feedback is greatly appreciated.
ChangeLog
Bugfix
Tests
builder_engine.go
builder_utils.go
builder.go
overlaybd_builder.go
I am not currenly sure how best to add the remaining functions due to their use of the overlaybd binaries. In the near term these should be covered by unit tests but leaving as a future work item.
fastoci_builder.go
Similar problem to above. Leaving for later.
End to End tests
Testing Tools
Local Remotes
This is an abstraction to interact with a local registry. The registry itself supports fetching, resolving, and pushes. See the local_registry.go file for more info. Along with this there is a mocks/registry folder which allows us to load stored images into the local registry for testing for now I've kept the added images small and restricted to hello-world but more can be added easily.
Filesystem interactivity
test_utils.go introduces RunTestWithTempDir which is a helper emulating the snapshotter tests that allows us to run a test with a temporary directory. This is useful for testing the filesystem interactions of several of the functions.
In Memory DB
In memory DB for testing DB related operations