mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Don't rerun certificate manager tests as subtests 1000 times.
Instead, run the core verification repeatedly.
This commit is contained in:
parent
7043372d05
commit
49987707a7
@ -202,7 +202,6 @@ func TestSetRotationDeadline(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
for i := 0; i < 1000; i++ {
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
m := manager{
|
m := manager{
|
||||||
cert: &tls.Certificate{
|
cert: &tls.Certificate{
|
||||||
@ -214,9 +213,11 @@ func TestSetRotationDeadline(t *testing.T) {
|
|||||||
template: &x509.CertificateRequest{},
|
template: &x509.CertificateRequest{},
|
||||||
usages: []certificates.KeyUsage{},
|
usages: []certificates.KeyUsage{},
|
||||||
}
|
}
|
||||||
m.setRotationDeadline()
|
|
||||||
lowerBound := tc.notBefore.Add(time.Duration(float64(tc.notAfter.Sub(tc.notBefore)) * 0.7))
|
lowerBound := tc.notBefore.Add(time.Duration(float64(tc.notAfter.Sub(tc.notBefore)) * 0.7))
|
||||||
upperBound := tc.notBefore.Add(time.Duration(float64(tc.notAfter.Sub(tc.notBefore)) * 0.9))
|
upperBound := tc.notBefore.Add(time.Duration(float64(tc.notAfter.Sub(tc.notBefore)) * 0.9))
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
// setRotationDeadline includes jitter, so this needs to run many times for validation.
|
||||||
|
m.setRotationDeadline()
|
||||||
if m.rotationDeadline.Before(lowerBound) || m.rotationDeadline.After(upperBound) {
|
if m.rotationDeadline.Before(lowerBound) || m.rotationDeadline.After(upperBound) {
|
||||||
t.Errorf("For notBefore %v, notAfter %v, the rotationDeadline %v should be between %v and %v.",
|
t.Errorf("For notBefore %v, notAfter %v, the rotationDeadline %v should be between %v and %v.",
|
||||||
tc.notBefore,
|
tc.notBefore,
|
||||||
@ -225,8 +226,8 @@ func TestSetRotationDeadline(t *testing.T) {
|
|||||||
lowerBound,
|
lowerBound,
|
||||||
upperBound)
|
upperBound)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user