-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRODENG-2719 refactor latest tag for msr (#500)
- hub latest tag detector refactored to also work with msr registries such as registry.mirantis.com ALSO - added a unit test that tests dockerhub and registry.mirantis.com tag check Signed-off-by: James Nesbitt <[email protected]>
- Loading branch information
1 parent
eea2d66
commit ab83ea5
Showing
4 changed files
with
179 additions
and
24 deletions.
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
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,74 @@ | ||
package phase | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Mirantis/mcc/pkg/docker/hub" | ||
"github.com/hashicorp/go-version" | ||
) | ||
|
||
func TestMKEVersionRetrieve(t *testing.T) { | ||
msrv, err := hub.LatestTag(hub.RegistryDockerHub, "mirantis", "ucp", false) | ||
if err != nil { | ||
t.Fatalf("Failed to retrieve MKE3 version: %s", err.Error()) | ||
} | ||
|
||
if msrv == "" { | ||
t.Fatal("Empty MKE3 version retrieved from registry") | ||
} | ||
|
||
msrV, err := version.NewVersion(msrv) | ||
if err != nil { | ||
t.Errorf("invalid MKE3 version response: %s", err.Error()) | ||
} | ||
|
||
msrTargetV, _ := version.NewVersion("3.0.0") | ||
|
||
if !msrV.GreaterThan(msrTargetV) { | ||
t.Errorf("Failed to detect newer version MKE3: %s (%s)", msrv, msrTargetV.String()) | ||
} | ||
} | ||
|
||
func TestMSR2VersionRetrieve(t *testing.T) { | ||
msrv, err := hub.LatestTag(hub.RegistryDockerHub, "mirantis", "dtr", false) | ||
if err != nil { | ||
t.Fatalf("Failed to retrieve MSR2 version: %s", err.Error()) | ||
} | ||
|
||
if msrv == "" { | ||
t.Fatal("Empty MSR2 version retrieved from registry") | ||
} | ||
|
||
msrV, err := version.NewVersion(msrv) | ||
if err != nil { | ||
t.Errorf("invalid MSR2 version response: %s", err.Error()) | ||
} | ||
|
||
msrTargetV, _ := version.NewVersion("2.9.0") | ||
|
||
if !msrV.GreaterThan(msrTargetV) { | ||
t.Errorf("Failed to detect newer version MSR2: %s (%s)", msrv, msrTargetV.String()) | ||
} | ||
} | ||
|
||
func TestMSR3VersionRetrieve(t *testing.T) { | ||
msrv, err := hub.LatestTag(hub.RegistryMirantis, "msr", "msr-api", false) | ||
if err != nil { | ||
t.Fatalf("Failed to retrieve MSR3 version: %s", err.Error()) | ||
} | ||
|
||
if msrv == "" { | ||
t.Fatal("Empty MSR3 version retrieved from registry") | ||
} | ||
|
||
msrV, err := version.NewVersion(msrv) | ||
if err != nil { | ||
t.Errorf("invalid MSR3 version response: %s", err.Error()) | ||
} | ||
|
||
msrTargetV, _ := version.NewVersion("3.0.0") | ||
|
||
if !msrV.GreaterThan(msrTargetV) { | ||
t.Errorf("Failed to detect newer version MSR3: %s (%s)", msrv, msrTargetV.String()) | ||
} | ||
} |