-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement Azure e2e template tests #300
Conversation
7dccbaa
to
eaf5033
Compare
You'll need to reopen this with a repository branch and modify the test to run as |
} | ||
|
||
if exists == nil { | ||
if _, err = dc.Create(ctx, credentialResource, metav1.CreateOptions{}); err != 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.
You don't even need to call .Get
prior to .Create
you can just call .Create
and then check for apierrors.IsAlreadyExists(err)
and return nil
in that case.
yamlDoc, err := yamlReader.Read() | ||
|
||
if err != nil { | ||
if err == io.EOF { |
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.
if err == io.EOF { | |
if errors.Is(err, io.EOF) { |
return fmt.Errorf("failed to read azure credential file: %w", err) | ||
} | ||
|
||
yamlFile, err = envsubst.Bytes(yamlFile) |
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.
If you're going to perform substitutions on the file it should probably be a .tpl
file. Perhaps create an resources/azure-credentials.yaml.tpl
and embed it above and then call envsubst
on it.
@@ -123,6 +131,75 @@ func new(configBytes []byte, namespace string) (*KubeClient, error) { | |||
}, nil | |||
} | |||
|
|||
func (kc *KubeClient) CreateAzureCredentialsKubeSecret(ctx context.Context) error { | |||
serializer := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme) | |||
yamlFile, err := os.ReadFile("./config/dev/azure-credentials.yaml") |
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.
Instead of calling os.ReadFile
on a path that might change use go:embed
to embed the file at runtime, see: https://gobyexample.com/embed-directive you can embed directly into []byte
and then manipulate it as needed below.
GinkgoHelper() | ||
|
||
generatedName := uuid.New().String()[:8] + "-e2e-test" | ||
generatedName := "e2etest-" + uuid.New().String()[:8] |
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.
Note that this name doesn't align with the one ran in CI, if you want to change that name to make sure you modify MANAGED_CLUSTER_NAME
in the actions workflow when you rebase.
@@ -41,7 +43,7 @@ func VerifyProviderDeleted(ctx context.Context, kc *kubeclient.KubeClient, clust | |||
func validateClusterDeleted(ctx context.Context, kc *kubeclient.KubeClient, clusterName string) error { | |||
// Validate that the Cluster resource has been deleted | |||
cluster, err := kc.GetCluster(ctx, clusterName) | |||
if err != nil { | |||
if err != nil && !apierrors.IsNotFound(err) { |
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.
👍
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.
The hosted test looks incorrect, should be rechecked and reworked.
Since hosted cluster should be create on cluster which is deployed on Azure. Also artifacts should be passed there somehow. I don't see any of that.
Probably you should wait for #280 to be merged and then build hosted CP tests on top of that.
|
||
for _, template := range []managedcluster.Template{ | ||
managedcluster.TemplateAzureStandaloneCP, | ||
managedcluster.TemplateAzureHostedCP, |
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.
You're creating hosted cluster template in the local kind cluster. It should fail. And if it's not - the test should be reworked
@@ -123,6 +131,75 @@ func new(configBytes []byte, namespace string) (*KubeClient, error) { | |||
}, nil | |||
} | |||
|
|||
func (kc *KubeClient) CreateAzureCredentialsKubeSecret(ctx context.Context) error { |
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.
It looks more complex than it should be. @squizzi already proposed several fixes and I tend to agree with him
Implement Azure template e2e tests.