Skip to content

Commit b818508

Browse files
committed
Make atelet CA rotation test independent of filesystem timing
Replace the trust bundle atomically to model projected-volume rotation and ensure the reload test does not depend on consecutive writes receiving distinct modification times. Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
1 parent aab12cc commit b818508

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎cmd/atelet/tlsconfig_test.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ func TestAteletServerTLSConfigReloadsCACertsWithoutRestart(t *testing.T) {
4949
t.Fatalf("GetConfigForClient() first call error = %v", err)
5050
}
5151

52-
if err := os.WriteFile(path, testCertPEM(t), 0o600); err != nil {
52+
// Replace the file like a projected-volume rotation, even when writes
53+
// share a filesystem timestamp.
54+
rotatedPath := path + ".rotated"
55+
if err := os.WriteFile(rotatedPath, testCertPEM(t), 0o600); err != nil {
5356
t.Fatalf("WriteFile() error = %v", err)
5457
}
58+
if err := os.Rename(rotatedPath, path); err != nil {
59+
t.Fatalf("Rename() error = %v", err)
60+
}
5561

5662
after, err := cfg.GetConfigForClient(nil)
5763
if err != nil {

0 commit comments

Comments
 (0)