Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spangenberg committed Oct 18, 2018
1 parent d9b2b5c commit 955966b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
20 changes: 6 additions & 14 deletions test/machines/awsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,27 @@ func (client *awsClientWrapper) GetRunningInstances(machine *clusterv1alpha1.Mac
}

func (client *awsClientWrapper) GetPublicDNSName(machine *clusterv1alpha1.Machine) (string, error) {
runningInstances, err := machineutils.GetRunningInstances(machine, client.client)
instance, err := machineutils.GetInstance(machine, client.client)
if err != nil {
return "", err
}

if len(runningInstances) == 0 {
return "", fmt.Errorf("no running machine instance found")
}

if *runningInstances[0].PublicDnsName == "" {
if *instance.PublicDnsName == "" {
return "", fmt.Errorf("machine instance public DNS name not set")
}

return *runningInstances[0].PublicDnsName, nil
return *instance.PublicDnsName, nil
}

func (client *awsClientWrapper) GetPrivateIP(machine *clusterv1alpha1.Machine) (string, error) {
runningInstances, err := machineutils.GetRunningInstances(machine, client.client)
instance, err := machineutils.GetInstance(machine, client.client)
if err != nil {
return "", err
}

if len(runningInstances) == 0 {
return "", fmt.Errorf("no running machine instance found")
}

if *runningInstances[0].PrivateIpAddress == "" {
if *instance.PrivateIpAddress == "" {
return "", fmt.Errorf("machine instance public DNS name not set")
}

return *runningInstances[0].PrivateIpAddress, nil
return *instance.PrivateIpAddress, nil
}
7 changes: 5 additions & 2 deletions test/machines/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ var _ = framework.SigKubeDescribe("Machines", func() {
testMachine := manifests.TestingMachine(cluster.Name, cluster.Namespace, testMachineProviderConfig)
awsClient, err := awsclient.NewClient(f.KubeClient, awsCredSecret.Name, awsCredSecret.Namespace, region)
Expect(err).NotTo(HaveOccurred())
acw := &awsClientWrapper{client: awsClient}
f.CreateMachineAndWait(testMachine, acw)
machinesToDelete.AddMachine(testMachine, f, acw)

f.CreateMachineAndWait(testMachine, &awsClientWrapper{client: awsClient})
machinesToDelete.AddMachine(testMachine, f, &awsClientWrapper{client: awsClient})

// TODO(jchaloup): Run some tests here!!! E.g. check for properly set security groups, iam role, tags

f.DeleteMachineAndWait(testMachine, &awsClientWrapper{client: awsClient})
f.DeleteMachineAndWait(testMachine, acw)
})

It("Can deploy compute nodes through machineset", func() {
Expand Down Expand Up @@ -207,7 +210,7 @@ var _ = framework.SigKubeDescribe("Machines", func() {
awsClient, err := awsclient.NewClient(f.KubeClient, awsCredSecret.Name, awsCredSecret.Namespace, region)
Expect(err).NotTo(HaveOccurred())
acw := &awsClientWrapper{client: awsClient}
f.CreateMachineAndWait(masterMachine, &awsClientWrapper{client: awsClient})
f.CreateMachineAndWait(masterMachine, acw)
machinesToDelete.AddMachine(masterMachine, f, acw)

By("Collecting master kubeconfig")
Expand Down

0 comments on commit 955966b

Please sign in to comment.