Skip to content

Commit 0e94448

Browse files
authored
test: Zone.create() appears to sometimes be eventually consistent (#370)
1 parent 912095d commit 0e94448

File tree

1 file changed

+12
-6
lines changed
  • packages/google-cloud-dns/system-test

1 file changed

+12
-6
lines changed

packages/google-cloud-dns/system-test/dns.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import {Metadata} from '@google-cloud/common';
2727
const dns = new DNS();
2828
const DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN || 'gitnpm.com.';
2929

30+
const delayMs = async (ms = 1000) => {
31+
return new Promise(resolve => {
32+
setTimeout(resolve, ms);
33+
});
34+
};
35+
3036
// Only run the tests if there is a domain to test with.
3137
describe('dns', () => {
3238
const ZONE_NAME = 'test-zone-' + uuid.v4().substr(0, 18);
@@ -117,12 +123,12 @@ describe('dns', () => {
117123
ZONE.delete({force: true}, done);
118124
});
119125

120-
it('should return 0 or more zones', done => {
121-
dns.getZones((err, zones) => {
122-
assert.ifError(err);
123-
assert(zones!.length >= 0);
124-
done();
125-
});
126+
// deal with eventual consistency of ZONE.create():
127+
it('should return 0 or more zones', async function() {
128+
this.retries(3);
129+
await delayMs(1000);
130+
const zones = await dns.getZones();
131+
assert(zones!.length >= 0);
126132
});
127133

128134
describe('Zones', () => {

0 commit comments

Comments
 (0)