mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 21:53:52 +00:00
kubeadm upgrade: fix unit test
The CA generated for each test case is global and the cases modify the expiry. This can flake depending on what order the tests run. Generate a new CA for each test case.
This commit is contained in:
@@ -136,10 +136,6 @@ func TestShouldBackupAPIServerCertAndKey(t *testing.T) {
|
|||||||
Networking: kubeadmapi.Networking{ServiceSubnet: "10.96.0.0/12", DNSDomain: "cluster.local"},
|
Networking: kubeadmapi.Networking{ServiceSubnet: "10.96.0.0/12", DNSDomain: "cluster.local"},
|
||||||
NodeName: "test-node",
|
NodeName: "test-node",
|
||||||
}
|
}
|
||||||
caCert, caKey, err := certsphase.NewCACertAndKey()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("failed creation of ca cert and key: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for desc, test := range map[string]struct {
|
for desc, test := range map[string]struct {
|
||||||
adjustedExpiry time.Duration
|
adjustedExpiry time.Duration
|
||||||
@@ -160,6 +156,10 @@ func TestShouldBackupAPIServerCertAndKey(t *testing.T) {
|
|||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
caCert, caKey, err := certsphase.NewCACertAndKey()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed creation of ca cert and key: %v", err)
|
||||||
|
}
|
||||||
caCert.NotBefore = caCert.NotBefore.Add(-test.adjustedExpiry).UTC()
|
caCert.NotBefore = caCert.NotBefore.Add(-test.adjustedExpiry).UTC()
|
||||||
apiCert, apiKey, err := certsphase.NewAPIServerCertAndKey(cfg, caCert, caKey)
|
apiCert, apiKey, err := certsphase.NewAPIServerCertAndKey(cfg, caCert, caKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user