-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get binary for specific version of EKS-A release in E2E tests #650
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
package framework | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/aws/eks-anywhere/internal/pkg/files" | ||
"github.com/aws/eks-anywhere/pkg/cluster" | ||
"github.com/aws/eks-anywhere/pkg/semver" | ||
"github.com/aws/eks-anywhere/pkg/validations" | ||
releasev1alpha1 "github.com/aws/eks-anywhere/release/api/v1alpha1" | ||
) | ||
|
||
const prodReleasesManifest = "https://anywhere-assets.eks.amazonaws.com/releases/eks-a/manifest.yaml" | ||
const ( | ||
prodReleasesManifest = "https://anywhere-assets.eks.amazonaws.com/releases/eks-a/manifest.yaml" | ||
releaseBinaryName = "eksctl-anywhere" | ||
) | ||
|
||
func (e *ClusterE2ETest) GetLatestMinorReleaseFromMain() *releasev1alpha1.EksARelease { | ||
func (e *ClusterE2ETest) GetLatestMinorReleaseFromMain() string { | ||
reader := cluster.NewManifestReader() | ||
e.T.Logf("Reading prod release manifest %s", prodReleasesManifest) | ||
releases, err := reader.GetReleases(prodReleasesManifest) | ||
|
@@ -28,10 +37,15 @@ func (e *ClusterE2ETest) GetLatestMinorReleaseFromMain() *releasev1alpha1.EksARe | |
e.T.Fatalf("Releases manifest doesn't contain latest release %s", releases.Spec.LatestVersion) | ||
} | ||
|
||
return latestRelease | ||
binaryPath, err := e.getBinary(latestRelease) | ||
if err != nil { | ||
e.T.Fatalf("Failed getting binary for latest release: %s", err) | ||
} | ||
|
||
return binaryPath | ||
} | ||
|
||
func (e *ClusterE2ETest) GetLatestMinorReleaseFromReleaseBranch(releaseBranchVersion *semver.Version) *releasev1alpha1.EksARelease { | ||
func (e *ClusterE2ETest) GetLatestMinorReleaseFromReleaseBranch(releaseBranchVersion *semver.Version) string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps this method should be "GetLatestMinorReleaseBinaryFromReleaseBranch" or "DownloadLatestMinorReleaseFromReleaseBranch" or something (I realize that's really long) that indicates that it not only gets the release object but actually downloads the binary itself There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I can change it to |
||
reader := cluster.NewManifestReader() | ||
e.T.Logf("Reading prod release manifest %s", prodReleasesManifest) | ||
releases, err := reader.GetReleases(prodReleasesManifest) | ||
|
@@ -60,5 +74,29 @@ func (e *ClusterE2ETest) GetLatestMinorReleaseFromReleaseBranch(releaseBranchVer | |
e.T.Fatalf("Releases manifest doesn't contain a version of the previous minor release") | ||
} | ||
|
||
return latestPrevMinorRelease | ||
binaryPath, err := e.getBinary(latestPrevMinorRelease) | ||
if err != nil { | ||
e.T.Fatalf("Failed getting binary for latest previous minor release: %s", err) | ||
} | ||
|
||
return binaryPath | ||
} | ||
|
||
func (e *ClusterE2ETest) getBinary(release *releasev1alpha1.EksARelease) (string, error) { | ||
latestReleaseBinaryFolder := filepath.Join("bin", release.Version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the directory will be in the format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes! |
||
latestReleaseBinaryPath := filepath.Join(latestReleaseBinaryFolder, releaseBinaryName) | ||
|
||
if !validations.FileExists(latestReleaseBinaryPath) { | ||
e.T.Logf("Downloading binary for EKS-A release [%s]", release.Version) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider logging the path as well (here and in the errors) |
||
err := os.MkdirAll(latestReleaseBinaryFolder, os.ModePerm) | ||
if err != nil { | ||
return "", fmt.Errorf("failed creating directory for release [%s]: %s", release.Version, err) | ||
} | ||
|
||
err = files.GzipFileDownloadExtract(release.EksABinary.LinuxBinary.URI, releaseBinaryName, latestReleaseBinaryFolder) | ||
if err != nil { | ||
return "", fmt.Errorf("failed extracting binary for release [%s]: %s", release.Version, err) | ||
} | ||
} | ||
return latestReleaseBinaryPath, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice this is very clear now