[e2e] Fix e2e suite
@@ -28,6 +28,7 @@ import (
"os"
"os/exec"
"path"
+ "reflect"
"testing"
"text/template"
@@ -160,13 +161,20 @@ var _ = BeforeSuite(func() {
var _ = AfterSuite(func() {
fmt.Fprintf(GinkgoWriter, "Tearing down kind cluster\n")
+
+ if reflect.TypeOf(kindClient) != nil {
retrieveAllLogs()
- if kindCluster != nil {
+ }
+
+ if kindCluster.Name != "" {
kindCluster.Teardown()
}
- if sess != nil {
+
+ if reflect.TypeOf(sess) != nil {
+ if accessKey != nil {
iamc := iam.New(sess)
iamc.DeleteAccessKey(&iam.DeleteAccessKeyInput{UserName: accessKey.UserName, AccessKeyId: accessKey.AccessKeyId})
+ }
deleteIAMRoles(sess)
}
@@ -183,7 +191,7 @@ func retrieveAllLogs() {
artifactPath, exists := os.LookupEnv("ARTIFACTS")
if exists {
logPath := path.Join(artifactPath, "logs")
- os.MkdirAll(logPath)
+ os.MkdirAll(logPath, 0755)
if capiLogs != "" {
ioutil.WriteFile(path.Join(logPath, "capi.log"), []byte(capiLogs), 0644)
}
@@ -198,7 +206,6 @@ func retrieveAllLogs() {
}
func retrieveLogs(namespace, deploymentName string) string {
- if kindClient != nil {
deployment := &appsv1.Deployment{}
Expect(kindClient.Get(context.TODO(), crclient.ObjectKey{Namespace: namespace, Name: deploymentName}, deployment)).To(Succeed())
pods := &corev1.PodList{}
@@ -222,8 +229,6 @@ func retrieveLogs(namespace, deploymentName string) string {
return buf.String()
}
- return ""
-}
func getSession() client.ConfigProvider {
sess, err := session.NewSessionWithOptions(session.Options{
