Skip to content

Commit

Permalink
Merge pull request #919 from gardener/fix-tests
Browse files Browse the repository at this point in the history
Fix/Update infra-test
  • Loading branch information
AndreasBurger authored Apr 10, 2024
2 parents 46067f9 + de96a9a commit 49c47fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
12 changes: 1 addition & 11 deletions test/integration/dnsrecord/dnsrecord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ var runTest = func(dns *extensionsv1alpha1.DNSRecord, stack awsclient.IPStack, n
By("verifying that the AWS DNS recordset exists and matches dnsrecord")
verifyDNSRecordSet(ctx, awsClient, dns, stack)

By("verifying that the meta AWS DNS recordset does not exist")
verifyMetaDNSRecordSetDeleted(ctx, awsClient, dns)

if len(newValues) > 0 {
if beforeUpdate != nil {
beforeUpdate()
Expand Down Expand Up @@ -299,9 +296,8 @@ var _ = Describe("DNSRecord tests", func() {
stack,
[]string{"3.3.3.3", "1.1.1.1"},
func() {
By("creating AWS DNS recordset and its meta recordset")
By("creating AWS DNS recordset")
Expect(awsClient.CreateOrUpdateDNSRecordSet(ctx, zoneID, dns.Spec.Name, route53.RRTypeA, []string{"8.8.8.8"}, 120, stack)).To(Succeed())
Expect(awsClient.CreateOrUpdateDNSRecordSet(ctx, zoneID, "comment-"+dns.Spec.Name, route53.RRTypeTxt, []string{"foo"}, 600, stack)).To(Succeed())
},
func() {
By("updating AWS DNS recordset")
Expand Down Expand Up @@ -477,12 +473,6 @@ func verifyDNSRecordSetDeleted(ctx context.Context, awsClient *awsclient.Client,
Expect(rrss).To(BeNil())
}

func verifyMetaDNSRecordSetDeleted(ctx context.Context, awsClient *awsclient.Client, dns *extensionsv1alpha1.DNSRecord) {
rrss, err := awsClient.GetDNSRecordSets(ctx, *dns.Status.Zone, "comment-"+dns.Spec.Name, route53.RRTypeTxt)
Expect(err).NotTo(HaveOccurred())
Expect(rrss).To(BeNil())
}

func deleteDNSRecordSet(ctx context.Context, awsClient *awsclient.Client, dns *extensionsv1alpha1.DNSRecord) {
err := awsClient.DeleteDNSRecordSet(ctx, *dns.Status.Zone, dns.Spec.Name, getRecordType(dns), nil, 0, awsclient.IPStackIPv4)
Expect(err).NotTo(HaveOccurred())
Expand Down
16 changes: 8 additions & 8 deletions test/integration/infrastructure/infrastructure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,14 +1215,14 @@ func verifyCreation(
describeNatGatewaysOutput, err := awsClient.EC2.DescribeNatGatewaysWithContext(ctx, &ec2.DescribeNatGatewaysInput{Filter: vpcIDFilter})
Expect(err).NotTo(HaveOccurred())
Expect(describeNatGatewaysOutput.NatGateways).To(HaveLen(1))
Expect(describeNatGatewaysOutput.NatGateways[0].NatGatewayAddresses).To(ConsistOf([]*ec2.NatGatewayAddress{
{
AllocationId: describeAddressesOutput.Addresses[0].AllocationId,
NetworkInterfaceId: describeAddressesOutput.Addresses[0].NetworkInterfaceId,
PrivateIp: describeAddressesOutput.Addresses[0].PrivateIpAddress,
PublicIp: describeAddressesOutput.Addresses[0].PublicIp,
},
}))
Expect(describeNatGatewaysOutput.NatGateways[0].NatGatewayAddresses).To(HaveLen(1))

natGatewayAddress := describeNatGatewaysOutput.NatGateways[0].NatGatewayAddresses[0]
Expect(natGatewayAddress).To(HaveField("AllocationId", Equal(describeAddressesOutput.Addresses[0].AllocationId)))
Expect(natGatewayAddress).To(HaveField("NetworkInterfaceId", Equal(describeAddressesOutput.Addresses[0].NetworkInterfaceId)))
Expect(natGatewayAddress).To(HaveField("PrivateIp", Equal(describeAddressesOutput.Addresses[0].PrivateIpAddress)))
Expect(natGatewayAddress).To(HaveField("PublicIp", Equal(describeAddressesOutput.Addresses[0].PublicIp)))

Expect(describeNatGatewaysOutput.NatGateways[0].SubnetId).To(PointTo(Equal(publicSubnetID)))
Expect(describeNatGatewaysOutput.NatGateways[0].Tags).To(ConsistOf([]*ec2.Tag{
{
Expand Down
20 changes: 10 additions & 10 deletions test/integration/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ func CreateVPC(ctx context.Context, log logr.Logger, awsClient *awsclient.Client
return "", "", err
}

_, err = awsClient.EC2.ModifyVpcAttribute(&ec2.ModifyVpcAttributeInput{
EnableDnsSupport: &ec2.AttributeBooleanValue{
Value: awssdk.Bool(true),
},
VpcId: vpcID,
})
if err != nil {
return "", "", err
}

if enableDnsHostnames {
_, err = awsClient.EC2.ModifyVpcAttribute(&ec2.ModifyVpcAttributeInput{
EnableDnsHostnames: &ec2.AttributeBooleanValue{
Expand All @@ -62,16 +72,6 @@ func CreateVPC(ctx context.Context, log logr.Logger, awsClient *awsclient.Client
}
}

_, err = awsClient.EC2.ModifyVpcAttribute(&ec2.ModifyVpcAttributeInput{
EnableDnsSupport: &ec2.AttributeBooleanValue{
Value: awssdk.Bool(true),
},
VpcId: vpcID,
})
if err != nil {
return "", "", err
}

createIgwOutput, err := awsClient.EC2.CreateInternetGateway(&ec2.CreateInternetGatewayInput{
TagSpecifications: awsclient.Tags{"Name": "aws-infrastructure-it-create-vpc"}.ToTagSpecifications(ec2.ResourceTypeInternetGateway),
})
Expand Down

0 comments on commit 49c47fc

Please sign in to comment.