Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions pkg/cache/cache_distributed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ func testDistributedDownloadDeduplication(factory distributedDBFactory) func(*te
require.NoError(t, err)

// Create separate upstream cache for each instance to avoid data races
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), &upstream.Options{
PublicKeys: testdata.PublicKeys(),
})
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), nil)
// Don't use public keys for distributed tests with generated entries
// since they don't have valid signatures (we don't have the private key to sign them)
require.NoError(t, err)

c, err := cache.New(
Expand Down Expand Up @@ -323,9 +323,9 @@ func testDistributedConcurrentReads(factory distributedDBFactory) func(*testing.
t.Cleanup(ts.Close)

// Create upstream cache
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), &upstream.Options{
PublicKeys: testdata.PublicKeys(),
})
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), nil)
// Don't use public keys for distributed tests with generated entries
// since they don't have valid signatures (we don't have the private key to sign them)
require.NoError(t, err)

// Create shared storage
Expand Down Expand Up @@ -742,9 +742,9 @@ func testLargeNARConcurrentDownloadScenario(t *testing.T, factory distributedDBF
cacheLocker, err := redis.NewRWLocker(ctx, redisCfg, retryCfg, false)
require.NoError(t, err)

uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), &upstream.Options{
PublicKeys: testdata.PublicKeys(),
})
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), nil)
// Don't use public keys for distributed tests with generated entries
// since they don't have valid signatures (we don't have the private key to sign them)
require.NoError(t, err)

c, err := cache.New(
Expand Down Expand Up @@ -982,9 +982,9 @@ func testCDCProgressiveStreamingDuringChunking(factory distributedDBFactory) fun
require.NoError(t, err)

// Create separate upstream cache for each instance to avoid data races
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), &upstream.Options{
PublicKeys: testdata.PublicKeys(),
})
uc, err := upstream.New(ctx, testhelper.MustParseURL(t, ts.URL), nil)
// Don't use public keys for distributed tests with generated entries
// since they don't have valid signatures (we don't have the private key to sign them)
require.NoError(t, err)

c, err := cache.New(
Expand Down
3 changes: 2 additions & 1 deletion pkg/cache/upstream/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func TestGetNarInfo(t *testing.T) {
ni, err := c.GetNarInfo(context.Background(), narEntry.NarInfoHash)
require.NoError(t, err)

assert.Equal(t, "nar/09xizkfyvigl5fqs0dhkn46nghfwwijbpdzzl4zg6kx90prjmsg0.nar", ni.URL)
expectedURL := "nar/09xizkfyvigl5fqs0dhkn46nghfwwijbpdzzl4zg6kx90prjmsg0.nar"
assert.Equal(t, expectedURL, ni.URL)
})
}
})
Expand Down
6 changes: 4 additions & 2 deletions testdata/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ func GenerateEntry(t *testing.T, narData []byte) (Entry, error) {

// Create narinfo text (using uncompressed NAR for simplicity in testing)
narURL := fmt.Sprintf("nar/%s.nar", narHash)
// Note: Generated entries do not include signatures since we don't have the private key.
// Tests using these entries should not use public key verification.
// Use the narinfo hash as a self-reference since this is a generated test package with no dependencies.
narInfoText := fmt.Sprintf(`StorePath: %s
URL: %s
Compression: none
FileHash: sha256:%s
FileSize: %d
NarHash: sha256:%s
NarSize: %d
References: %s
Sig: test-cache:1:fakesignature==`,
References: %s-generated-test`,
Comment on lines 33 to +40
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The generated References field seems inconsistent with the StorePath. The comment mentions using a self-reference, which typically means using the basename of the package's own store path.

The StorePath is .../<narInfoHash>-generated-test-package, so its basename is <narInfoHash>-generated-test-package.
However, the References field is being set to <narInfoHash>-generated-test.

To make this consistent, the References field should probably be <narInfoHash>-generated-test-package. This would make it a true self-reference to the store path's basename.

Suggested change
narInfoText := fmt.Sprintf(`StorePath: %s
URL: %s
Compression: none
FileHash: sha256:%s
FileSize: %d
NarHash: sha256:%s
NarSize: %d
References: %s
Sig: test-cache:1:fakesignature==`,
References: %s-generated-test`,
narInfoText := fmt.Sprintf(`StorePath: %s
URL: %s
Compression: none
FileHash: sha256:%s
FileSize: %d
NarHash: sha256:%s
NarSize: %d
References: %s-generated-test-package`,

storePath,
narURL,
narHash,
Expand Down