-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3390 from vardhaman22/change-etcd-restore-contain…
…er-image changed etcd restore image to rke-tools for etcd >=3.5.7
- Loading branch information
Showing
2 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cluster | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/rancher/rke/metadata" | ||
"github.com/rancher/rke/types" | ||
v3 "github.com/rancher/rke/types" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetRestoreImage(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
metadata.InitMetadata(ctx) | ||
|
||
cluster := &Cluster{ | ||
RancherKubernetesEngineConfig: v3.RancherKubernetesEngineConfig{ | ||
SystemImages: types.RKESystemImages{ | ||
Etcd: "rancher/mirrored-coreos-etcd:v3.5.7", | ||
Alpine: "rancher/rke-tools:v0.1.90", | ||
}, | ||
}, | ||
} | ||
|
||
expectedRestoreImage := cluster.getBackupImage() | ||
restoreImage := cluster.getRestoreImage() | ||
|
||
assert.NotEmpty(t, restoreImage, "") | ||
assert.Equal(t, expectedRestoreImage, restoreImage, | ||
"expected restoreImage is different when etcd image version is v3.5.7") | ||
|
||
cluster.SystemImages.Etcd = "rancher/mirrored-coreos-etcd:v3.5.8" | ||
|
||
expectedRestoreImage = cluster.getBackupImage() | ||
restoreImage = cluster.getRestoreImage() | ||
|
||
assert.NotEmpty(t, restoreImage, "") | ||
assert.Equal(t, expectedRestoreImage, restoreImage, | ||
"expected restoreImage is different when etcd image version is greater than v3.5.7") | ||
|
||
cluster.SystemImages.Etcd = "rancher/mirrored-coreos-etcd:v3.5.6" | ||
|
||
expectedRestoreImage = cluster.SystemImages.Etcd | ||
restoreImage = cluster.getRestoreImage() | ||
|
||
assert.NotEmpty(t, restoreImage, "") | ||
assert.Equal(t, expectedRestoreImage, restoreImage, | ||
"expected restoreImage is different when etcd image version is less than v3.5.7") | ||
|
||
// test for custom image | ||
cluster.SystemImages.Etcd = "custom/mirrored-coreos-etcd:v3.5.7" | ||
|
||
expectedRestoreImage = cluster.SystemImages.Etcd | ||
restoreImage = cluster.getRestoreImage() | ||
|
||
assert.NotEmpty(t, restoreImage, "") | ||
assert.Equal(t, expectedRestoreImage, restoreImage, | ||
"expected restoreImage is different when custom etcd image is used") | ||
} |