Skip to content

Commit 60b7c60

Browse files
justaugustusk8s-ci-robot
authored andcommitted
test/e2e: Quick cleanup of presubmit failures, deadcode, copyrights (#265)
Signed-off-by: Stephen Augustus <[email protected]>
1 parent a994d89 commit 60b7c60

File tree

4 files changed

+41
-96
lines changed

4 files changed

+41
-96
lines changed

test/e2e/BUILD.bazel

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,20 @@ go_test(
5555
tags = ["external"],
5656
deps = [
5757
"//pkg/apis/azureprovider/v1alpha1:go_default_library",
58-
"//pkg/cloud/azure/actuators:go_default_library",
59-
"//pkg/cloud/azure/actuators/machine:go_default_library",
60-
"//pkg/cloudtest:go_default_library",
6158
"//test/e2e/util/kind:go_default_library",
6259
"//vendor/github.com/onsi/ginkgo:go_default_library",
6360
"//vendor/github.com/onsi/gomega:go_default_library",
6461
"//vendor/github.com/onsi/gomega/gstruct:go_default_library",
6562
"//vendor/github.com/onsi/gomega/types:go_default_library",
63+
"//vendor/k8s.io/api/apps/v1:go_default_library",
6664
"//vendor/k8s.io/api/core/v1:go_default_library",
65+
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
6766
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
68-
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
69-
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
67+
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
7068
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
7169
"//vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1:go_default_library",
72-
"//vendor/sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset:go_default_library",
70+
"//vendor/sigs.k8s.io/cluster-api/pkg/util:go_default_library",
71+
"//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library",
7372
],
7473
)
7574

test/e2e/azure_test.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ import (
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
apimachinerytypes "k8s.io/apimachinery/pkg/types"
3333
"k8s.io/client-go/kubernetes"
34+
capz "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1"
3435
capi "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
3536
"sigs.k8s.io/cluster-api/pkg/util"
3637
crclient "sigs.k8s.io/controller-runtime/pkg/client"
37-
38-
capz "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1"
39-
//capa "sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsprovider/v1alpha1"
4038
)
4139

4240
const (
43-
workerClusterK8sVersion = "v1.15.1"
41+
workerClusterK8sVersion = "v1.15.3"
4442
)
4543

4644
var _ = Describe("functional tests", func() {
@@ -80,17 +78,17 @@ var _ = Describe("functional tests", func() {
8078

8179
fmt.Fprintf(GinkgoWriter, "Ensuring first control plane Machine is ready\n")
8280
Eventually(
83-
func() (*capa.AWSMachineProviderStatus, error) {
81+
func() (*capz.AzureMachineProviderStatus, error) {
8482
machine := &capi.Machine{}
8583
if err := kindClient.Get(context.TODO(), apimachinerytypes.NamespacedName{Namespace: namespace, Name: machineName}, machine); err != nil {
8684
return nil, err
8785
}
8886
if machine.Status.ProviderStatus == nil {
89-
return &capa.AWSMachineProviderStatus{
90-
InstanceState: &capa.InstanceStatePending,
87+
return &capz.AzureMachineProviderStatus{
88+
VMState: &capz.VMStateCreating,
9189
}, nil
9290
}
93-
return capa.MachineStatusFromProviderStatus(machine.Status.ProviderStatus)
91+
return capz.MachineStatusFromProviderStatus(machine.Status.ProviderStatus)
9492
},
9593
10*time.Minute, 15*time.Second,
9694
).Should(beHealthy())
@@ -118,7 +116,7 @@ var _ = Describe("functional tests", func() {
118116
return cluster.Annotations, nil
119117
},
120118
10*time.Minute, 15*time.Second,
121-
).Should(HaveKeyWithValue(capa.AnnotationControlPlaneReady, capa.ValueReady))
119+
).Should(HaveKeyWithValue(capz.AnnotationControlPlaneReady, capz.ValueReady))
122120

123121
// TODO: Retrieve Cluster kubeconfig
124122
// TODO: Deploy Addons
@@ -161,15 +159,14 @@ func noOptionsDelete() crclient.DeleteOptionFunc {
161159
func beHealthy() types.GomegaMatcher {
162160
return PointTo(
163161
MatchFields(IgnoreExtras, Fields{
164-
"InstanceState": PointTo(Equal(capz.InstanceStateRunning)),
162+
"VMState": PointTo(Equal(capz.VMStateSucceeded)),
165163
}),
166164
)
167165
}
168166

169167
func makeCluster(name string) *capi.Cluster {
170168
providerSpecValue, err := capz.EncodeClusterSpec(&capz.AzureClusterProviderSpec{
171-
SSHKeyName: keyPairName,
172-
Region: region,
169+
// TODO: Determine bare minimum cluster spec to define here
173170
})
174171
Expect(err).To(BeNil())
175172

@@ -207,14 +204,13 @@ func makeMachine(name, clusterName, role, k8sVersion string) *capi.Machine {
207204
instanceRole = "control-plane.cluster-api-provider-azure.sigs.k8s.io"
208205
machineVersionInfo.ControlPlane = k8sVersion
209206
case "node":
210-
instanceRole = "nodes.cluster-api-provider-aws.sigs.k8s.io"
207+
instanceRole = "nodes.cluster-api-provider-azure.sigs.k8s.io"
211208
}
212209
Expect(instanceRole).ToNot(BeEmpty())
213210

214211
providerSpecValue, err := capz.EncodeMachineSpec(&capz.AzureMachineProviderSpec{
215-
// KeyName: keyPairName,
216-
// IAMInstanceProfile: instanceRole,
217-
VMSize: "m5.large", //LOOK UP ACTUAL AZURE VM SIZES
212+
// TODO: Determine bare minimum machine spec to define here
213+
VMSize: "Standard_B2ms",
218214
})
219215
Expect(err).To(BeNil())
220216

test/e2e/e2e_suite_test.go

Lines changed: 20 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/*
2-
Copyright 2018 The Kubernetes Authors.
2+
Copyright 2019 The Kubernetes Authors.
3+
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
56
You may obtain a copy of the License at
7+
68
http://www.apache.org/licenses/LICENSE-2.0
9+
710
Unless required by applicable law or agreed to in writing, software
811
distributed under the License is distributed on an "AS IS" BASIS,
912
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,32 +25,18 @@ import (
2225
"testing"
2326
"time"
2427

25-
"github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/awserrors"
26-
"github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/cloudformation"
27-
"github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/sts"
2828
. "github.com/onsi/ginkgo"
2929
. "github.com/onsi/gomega"
3030

31-
// "github.com/aws/aws-sdk-go/aws"
32-
// "github.com/aws/aws-sdk-go/aws/client"
33-
// "github.com/aws/aws-sdk-go/aws/credentials"
34-
// "github.com/aws/aws-sdk-go/aws/session"
35-
// cfn "github.com/aws/aws-sdk-go/service/cloudformation"
36-
// "github.com/aws/aws-sdk-go/service/ec2"
37-
// awssts "github.com/aws/aws-sdk-go/service/sts"
3831
appsv1 "k8s.io/api/apps/v1"
3932
apimachinerytypes "k8s.io/apimachinery/pkg/types"
33+
"sigs.k8s.io/cluster-api-provider-azure/test/e2e/util/kind"
4034
"sigs.k8s.io/cluster-api/pkg/util"
4135
crclient "sigs.k8s.io/controller-runtime/pkg/client"
42-
43-
// "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/awserrors"
44-
// "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/cloudformation"
45-
// "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/sts"
46-
"sigs.k8s.io/cluster-api-provider-azure/test/e2e/util/kind"
4736
)
4837

4938
func TestE2e(t *testing.T) {
50-
if err := initRegion(); err != nil {
39+
if err := initLocation(); err != nil {
5140
t.Fatal(err)
5241
}
5342
RegisterFailHandler(Fail)
@@ -58,21 +47,18 @@ const (
5847
setupTimeout = 10 * 60
5948
capzProviderNamespace = "azure-provider-system"
6049
capzStatefulSetName = "azure-provider-controller-manager"
61-
stackName = "cluster-api-provider-azure-sigs-k8s-io"
62-
keyPairName = "cluster-api-provider-azure-sigs-k8s-io"
6350
)
6451

6552
var (
66-
credFile = flag.String("credFile", "", "path to an Azure credentials file")
67-
regionFile = flag.String("regionFile", "", "The path to a text file containing the Azure region")
53+
// TODO: Do we want to do file-based auth? Not suggested. If we determine no, remove this deadcode
54+
//credFile = flag.String("credFile", "", "path to an Azure credentials file")
55+
locationFile = flag.String("locationFile", "", "The path to a text file containing the Azure location")
6856
providerComponentsYAML = flag.String("providerComponentsYAML", "", "path to the provider components YAML for the cluster API")
6957
managerImageTar = flag.String("managerImageTar", "", "a script to load the manager Docker image into Docker")
7058

7159
kindCluster kind.Cluster
7260
kindClient crclient.Client
73-
sess client.ConfigProvider
74-
accountID string
75-
region string
61+
location string
7662
)
7763

7864
var _ = BeforeSuite(func() {
@@ -91,10 +77,7 @@ var _ = BeforeSuite(func() {
9177
Expect(err).To(BeNil())
9278

9379
fmt.Fprintf(GinkgoWriter, "Creating Azure prerequisites\n")
94-
// sess = getSession()
95-
// accountID = getAccountID(sess)
96-
// createKeyPair(sess)
97-
// createIAMRoles(sess, accountID)
80+
// TODO: Probably need to init auth session to Azure here
9881

9982
fmt.Fprintf(GinkgoWriter, "Ensuring ProviderComponents are deployed\n")
10083
Eventually(
@@ -107,66 +90,30 @@ var _ = BeforeSuite(func() {
10790
}, 5*time.Minute, 15*time.Second,
10891
).ShouldNot(BeZero())
10992

110-
fmt.Fprintf(GinkgoWriter, "Running in Azure region: %s\n", region)
93+
fmt.Fprintf(GinkgoWriter, "Running in Azure location: %s\n", location)
11194
}, setupTimeout)
11295

11396
var _ = AfterSuite(func() {
11497
fmt.Fprintf(GinkgoWriter, "Tearing down kind cluster\n")
11598
kindCluster.Teardown()
11699
})
117100

118-
func initRegion() error {
119-
if regionFile != nil && *regionFile != "" {
120-
data, err := ioutil.ReadFile(*regionFile)
101+
// TODO: Determine if we need this
102+
func initLocation() error {
103+
if locationFile != nil && *locationFile != "" {
104+
data, err := ioutil.ReadFile(*locationFile)
121105
if err != nil {
122-
return fmt.Errorf("error reading AWS region file: %v", err)
106+
return fmt.Errorf("error reading AWS location file: %v", err)
123107
}
124-
region = string(bytes.TrimSpace(data))
108+
location = string(bytes.TrimSpace(data))
125109
return nil
126110
}
127111

128-
region = "eastus2"
112+
location = "eastus"
129113
return nil
130114
}
131115

132-
func getSession() client.ConfigProvider {
133-
if credFile != nil && *credFile != "" {
134-
creds := credentials.NewCredentials(&credentials.SharedCredentialsProvider{
135-
Filename: *credFile,
136-
})
137-
sess, err := session.NewSession(aws.NewConfig().WithCredentials(creds).WithRegion(region))
138-
Expect(err).To(BeNil())
139-
return sess
140-
}
141-
142-
sess, err := session.NewSessionWithOptions(session.Options{
143-
SharedConfigState: session.SharedConfigEnable,
144-
})
145-
Expect(err).To(BeNil())
146-
return sess
147-
}
148-
149-
func getAccountID(prov client.ConfigProvider) string {
150-
stsSvc := sts.NewService(awssts.New(prov))
151-
accountID, err := stsSvc.AccountID()
152-
Expect(err).To(BeNil())
153-
return accountID
154-
}
155-
156-
func createIAMRoles(prov client.ConfigProvider, accountID string) {
157-
cfnSvc := cloudformation.NewService(cfn.New(prov))
158-
Expect(
159-
cfnSvc.ReconcileBootstrapStack(stackName, accountID),
160-
).To(Succeed())
161-
}
162-
163-
func createKeyPair(prov client.ConfigProvider) {
164-
ec2c := ec2.New(prov)
165-
_, err := ec2c.CreateKeyPair(&ec2.CreateKeyPairInput{KeyName: aws.String(keyPairName)})
166-
if code, _ := awserrors.Code(err); code != "InvalidKeyPair.Duplicate" {
167-
Expect(err).To(BeNil())
168-
}
169-
}
116+
// TODO: Add function to handle auth to Azure
170117

171118
func loadManagerImage(kindCluster kind.Cluster) {
172119
if managerImageTar != nil && *managerImageTar != "" {

test/e2e/util/kind/setup.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/*
2-
Copyright 2018 The Kubernetes Authors.
2+
Copyright 2019 The Kubernetes Authors.
3+
34
Licensed under the Apache License, Version 2.0 (the "License");
45
you may not use this file except in compliance with the License.
56
You may obtain a copy of the License at
7+
68
http://www.apache.org/licenses/LICENSE-2.0
9+
710
Unless required by applicable law or agreed to in writing, software
811
distributed under the License is distributed on an "AS IS" BASIS,
912
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

0 commit comments

Comments
 (0)