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

test: introduce a special "cherry-picking" mock server for providing local databases #1603

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Feb 11, 2025

Currently the CLI tests for the local databases are the slowest as they involve downloading zip files multiple times and the databases in particular include ones like Debian and OSS-Fuzz which are the largest of the lot - with the TestRun_LocalDatabases cases included, the suite takes about 90 seconds to run, whereas without it it takes less than 30 seconds.

This attempts to improve the performance of our test suite by introducing a mocking server that acts like the GCP storage bucket which serves in-memory zip files containing specific OSVs for each ecosystem that have been "cherry-picked", which brings us back to around the 30 second mark.

Aside from the downside of this being a fake GCP storage bucket (which is technically a downside, but I doubt the behaviour of GCP storage is going to change significantly enough to make this an actual risk), this does mean we miss out on testing both the zip-based databases and the specific OSVs they contain.

On the other hand, this does mean we shouldn't have to update snapshots as often since we control exactly what OSVs are included in the checks.

Resolves #1567

@@ -18,6 +20,210 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}

// localmatcher.ZippedDBRemoteHost = testdb.NewZipDBCacheServer().URL
localmatcher.ZippedDBRemoteHost = testdb.NewZipDBCherryPickServer(map[string][]string{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for now I just copied all the OSVs that were present in the snapshots for each database

return
}

b, err := os.ReadFile(db.StoredAt)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High test

This path depends on a
user-provided value
.
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.

Lower the time tests take to run
1 participant