mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
test: fix helm test flake (#27275)
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
parent
de9416137d
commit
bd823728ac
1 changed files with 6 additions and 21 deletions
|
|
@ -461,31 +461,16 @@ func TestGenerateManifest_RefOnlyShortCircuit(t *testing.T) {
|
|||
|
||||
// Test that calling manifest generation on source helm reference helm files that when the revision is cached it does not call ls-remote
|
||||
func TestGenerateManifestsHelmWithRefs_CachedNoLsRemote(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// Use os.MkdirTemp instead of t.TempDir() because the async goroutine in
|
||||
// runManifestGenAsync sets directory permissions to 0o000 (via
|
||||
// directoryPermissionInitializer) after GenerateManifest returns, racing
|
||||
// with t.TempDir()'s implicit RemoveAll cleanup.
|
||||
dir, mkErr := os.MkdirTemp("", "TestGenerateManifestsHelmWithRefs_CachedNoLsRemote")
|
||||
require.NoError(t, mkErr)
|
||||
repopath := dir + "/tmprepo"
|
||||
cacheMocks := newCacheMocks()
|
||||
t.Cleanup(func() {
|
||||
cacheMocks.mockCache.StopRedisCallback()
|
||||
// Best-effort: make all files writable so t.TempDir() can clean up.
|
||||
// Ignore errors (e.g. git object files with restrictive permissions in CI)
|
||||
// to avoid failing the test in the cleanup phase rather than the logic phase.
|
||||
// We chmod *before* descending so that directories with restrictive permissions
|
||||
// (e.g. git object dirs set to 0444) become accessible prior to listing their
|
||||
// entries. filepath.WalkDir cannot be used here because it reads directory
|
||||
// entries before calling the callback, so a dir with 0000/0444 perms would
|
||||
// already fail before we get a chance to fix it.
|
||||
var fixPerms func(string)
|
||||
fixPerms = func(path string) {
|
||||
_ = os.Chmod(path, 0o777)
|
||||
entries, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, e := range entries {
|
||||
fixPerms(filepath.Join(path, e.Name()))
|
||||
}
|
||||
}
|
||||
fixPerms(dir)
|
||||
})
|
||||
service := NewService(metrics.NewMetricsServer(), cacheMocks.cache, RepoServerInitConstants{ParallelismLimit: 1}, &git.NoopCredsStore{}, repopath)
|
||||
var gitClient git.Client
|
||||
|
|
|
|||
Loading…
Reference in a new issue