maximilien / softlayer-go

A SoftLayer client API written in Golang
Apache License 2.0
17 stars 24 forks source link

Integration tests fail on polling DNS domain deletion #106

Open sykesm opened 8 years ago

sykesm commented 8 years ago

After successfully creating, retrieving, and deleting a domain, the test fails:

• Failure [2.573 seconds]
SoftLayer DNS domains
/Users/sykesm/workspace/softlayer-go/src/github.com/maximilien/softlayer-go/integration/dns_domain/dns_domain_test.go:45
  SoftLayer_Dns_Domain
  /Users/sykesm/workspace/softlayer-go/src/github.com/maximilien/softlayer-go/integration/dns_domain/dns_domain_test.go:44
    creates a DNS Domain, update it, and delete it [It]
    /Users/sykesm/workspace/softlayer-go/src/github.com/maximilien/softlayer-go/integration/dns_domain/dns_domain_test.go:43

    Expected error:
        <*errors.errorString | 0xc82030a190>: {
            s: "softlayer-go: could not SoftLayer_Dns_Domain#getObject, HTTP error code: '404'",
        }
        softlayer-go: could not SoftLayer_Dns_Domain#getObject, HTTP error code: '404'
    not to have occurred

    /Users/sykesm/workspace/softlayer-go/src/github.com/maximilien/softlayer-go/test_helpers/test_helpers.go:746
------------------------------

Summarizing 1 Failure:

[Fail] SoftLayer DNS domains SoftLayer_Dns_Domain [It] creates a DNS Domain, update it, and delete it 
/Users/sykesm/workspace/softlayer-go/src/github.com/maximilien/softlayer-go/test_helpers/test_helpers.go:746

Ran 1 of 1 Specs in 2.591 seconds
FAIL! -- 0 Passed | 1 Failed | 0 Pending | 0 Skipped 

Looks like WaitForDeletedDnsDomainToNoLongerBePresent fails because, after deletion, the domain can't be retrieved and the production code turns the 404 into an error.

func WaitForDeletedDnsDomainToNoLongerBePresent(dnsDomainId int) {
    dnsDomainService, err := CreateDnsDomainService()
    Expect(err).ToNot(HaveOccurred())

    fmt.Printf("----> waiting for deleted dns domain to no longer be present\n")
    Eventually(func() bool {
        dnsDomain, err := dnsDomainService.GetObject(dnsDomainId)
        Expect(err).ToNot(HaveOccurred())

        if dnsDomain.Id == dnsDomainId {
            return false
        }
        return true
    }, TIMEOUT, POLLING_INTERVAL).Should(BeTrue(), "failed waiting for deleted dns domain to be removed")
}

I'm not sure how this ever worked.

Also, for logging in tests, you should consider using GinkgoWriter as described in the doc instead of fmt.Printf.

maximilien commented 8 years ago

@sykesm I'll take a look at the failure. Moving the suggesting of using GinkgoWriter as separate issue #109