-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds basic eks workflow structure * * Added EKS functional test set up + teardown. (#79) - Adding EKS test set up * creates GenericImageBuilderTestSuite for use by multiple cloud implementations * * Updated EKS functional test set up to use the shared functions. * * Split the repo URL to access the registry and repo in ECR. * * Added parsing of the repository URL. * * Updated testenv to include kubeconfig changes. * Added filename to EKS set up. * updates testenv dep and adds aws-sdk so we can pull ecr credentials * changes cert-manager default webhook port to avoid collision with eks' default kubelet port...hurumph * fixes GenericImageBuilderTestSuite so that a new CloudAuthTest func can encapsulate the details of each cloud enviornment also makes some changes to the LoadBalancer service lookup checking for the Hostname first, then defaulting to the IP when that's blank * updates functional test workflow with complete EKS Co-authored-by: Jade <[email protected]> Co-authored-by: Jade Hayes <[email protected]>
- Loading branch information
1 parent
f3cbeb1
commit 1e126f4
Showing
7 changed files
with
712 additions
and
460 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,86 @@ | ||
//go:build functional && eks | ||
|
||
package functional | ||
|
||
import ( | ||
"context" | ||
"encoding/base64" | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
"github.com/aws/aws-sdk-go-v2/config" | ||
"github.com/aws/aws-sdk-go-v2/service/ecr" | ||
hephv1 "github.com/dominodatalab/hephaestus/pkg/api/hephaestus/v1" | ||
"github.com/dominodatalab/testenv" | ||
"github.com/heroku/docker-registry-client/registry" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
"k8s.io/utils/pointer" | ||
) | ||
|
||
func TestEKSFunctionality(t *testing.T) { | ||
suite.Run(t, new(EKSTestSuite)) | ||
} | ||
|
||
type EKSTestSuite struct { | ||
GenericImageBuilderTestSuite | ||
|
||
region string | ||
} | ||
|
||
func (suite *EKSTestSuite) SetupSuite() { | ||
suite.region = os.Getenv("AWS_REGION") | ||
suite.CloudAuthTest = suite.testCloudAuth | ||
suite.CloudConfigFunc = func() testenv.CloudConfig { | ||
return testenv.EKSConfig{ | ||
Region: suite.region, | ||
KubernetesVersion: os.Getenv("KUBERNETES_VERSION"), | ||
} | ||
} | ||
|
||
suite.GenericImageBuilderTestSuite.SetupSuite() | ||
} | ||
|
||
func (suite *EKSTestSuite) testCloudAuth(ctx context.Context, t *testing.T) { | ||
fullRepo, err := suite.manager.OutputVar(ctx, "repository") | ||
require.NoError(t, err) | ||
|
||
canonicalImage := string(fullRepo) | ||
cloudRegistry := strings.SplitN(canonicalImage, "/", 2)[0] | ||
cloudRepository := strings.SplitN(canonicalImage, "/", 2)[1] | ||
|
||
build := newImageBuild( | ||
python39JupyterBuildContext, | ||
canonicalImage, | ||
&hephv1.RegistryCredentials{ | ||
Server: cloudRegistry, | ||
CloudProvided: pointer.Bool(true), | ||
}, | ||
) | ||
ib := createBuild(t, ctx, suite.hephClient, build) | ||
|
||
conf, err := config.LoadDefaultConfig(ctx, config.WithEC2IMDSRegion()) | ||
require.NoError(t, err) | ||
|
||
client := ecr.NewFromConfig(conf) | ||
input := &ecr.GetAuthorizationTokenInput{} | ||
resp, err := client.GetAuthorizationToken(ctx, input) | ||
require.NoError(t, err) | ||
|
||
authToken := aws.ToString(resp.AuthorizationData[0].AuthorizationToken) | ||
decoded, err := base64.StdEncoding.DecodeString(authToken) | ||
require.NoError(t, err) | ||
|
||
credentials := strings.SplitN(string(decoded), ":", 2) | ||
|
||
hub, err := registry.New(fmt.Sprintf("https://%s", cloudRegistry), credentials[0], credentials[1]) | ||
require.NoError(t, err) | ||
|
||
tags, err := hub.Tags(cloudRepository) | ||
require.NoError(t, err) | ||
assert.Contains(t, tags, ib.Spec.LogKey) | ||
} |
Oops, something went wrong.