Skip to content

Commit

Permalink
Add additional assertions to e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
spangenberg committed Oct 18, 2018
1 parent 955966b commit ac2d65e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
37 changes: 37 additions & 0 deletions test/machines/awsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,40 @@ func (client *awsClientWrapper) GetPrivateIP(machine *clusterv1alpha1.Machine) (

return *instance.PrivateIpAddress, nil
}

func (client *awsClientWrapper) GetSecurityGroups(machine *clusterv1alpha1.Machine) ([]string, error) {
instance, err := machineutils.GetInstance(machine, client.client)
if err != nil {
return nil, err
}
var groups []string
for _, groupIdentifier := range instance.SecurityGroups {
if *groupIdentifier.GroupName != "" {
groups = append(groups, *groupIdentifier.GroupName)
}
}
return groups, nil
}

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

func (client *awsClientWrapper) GetTags(machine *clusterv1alpha1.Machine) (map[string]string, error) {
instance, err := machineutils.GetInstance(machine, client.client)
if err != nil {
return nil, err
}
tags := make(map[string]string, len(instance.Tags))
for _, tag := range instance.Tags {
tags[*tag.Key] = *tag.Value
}
return tags, nil
}
20 changes: 17 additions & 3 deletions test/machines/machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,24 @@ var _ = framework.SigKubeDescribe("Machines", func() {
f.CreateMachineAndWait(testMachine, acw)
machinesToDelete.AddMachine(testMachine, f, acw)

f.CreateMachineAndWait(testMachine, &awsClientWrapper{client: awsClient})
machinesToDelete.AddMachine(testMachine, f, &awsClientWrapper{client: awsClient})
securityGroups, err := acw.GetSecurityGroups(testMachine)
Expect(err).NotTo(HaveOccurred())
Expect(securityGroups).To(Equal([]string{fmt.Sprintf("%s-default", clusterID)}))

iamRole, err := acw.GetIAMRole(testMachine)
Expect(err).NotTo(HaveOccurred())
Expect(iamRole).To(Equal(""))

// TODO(jchaloup): Run some tests here!!! E.g. check for properly set security groups, iam role, tags
tags, err := acw.GetTags(testMachine)
Expect(err).NotTo(HaveOccurred())
Expect(tags).To(Equal(map[string]string{
fmt.Sprintf("kubernetes.io/cluster/%s", clusterID): "owned",
"openshift-node-group-config": "node-config-master",
"sub-host-type": "default",
"host-type": "master",
"Name": testMachine.Name,
"clusterid": clusterID,
}))

f.DeleteMachineAndWait(testMachine, acw)
})
Expand Down

0 comments on commit ac2d65e

Please sign in to comment.