Skip to content

Commit

Permalink
build: increase system test timeout to 20 minutes (#329)
Browse files Browse the repository at this point in the history
* build: use async before/after functions

* fix `filterExpired` calls

* lonely only

* ensure array

* remove rules before proxies

* services deleting order preserved

* bump timeout to 20 minutes
  • Loading branch information
stephenplusplus authored Jun 20, 2019
1 parent f83672d commit ad4797d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-compute/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"docs": "jsdoc -c .jsdoc.js",
"lint": "eslint '**/*.js'",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"system-test": "mocha system-test/*.js --timeout 600000",
"system-test": "mocha system-test/*.js --timeout 1200000",
"test": "nyc mocha",
"fix": "eslint --fix '**/*.js'",
"docs-test": "linkinator docs -r --skip www.googleapis.com",
Expand Down
62 changes: 15 additions & 47 deletions packages/google-cloud-compute/system-test/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,11 @@ describe('Compute', () => {

async function deleteAllTestObjects(opts) {
opts.name = opts.expiredOnly ? TESTS_PREFIX : FULL_PREFIX;
await deleteGlobalRules(opts);
await deleteRegionalRules(opts);
await callAndDeleteGcloudTestObject('Rules', opts);
await deleteTargetProxies(opts);
await deleteUrlMaps(opts);
await deleteServices(opts);
await callAndDeleteGcloudTestObject('Services', opts);
await deleteHttpsHealthChecks(opts);
await deleteInstanceGroupManagers(opts);
await deleteInstanceTemplates(opts);
Expand All @@ -1139,7 +1139,6 @@ describe('Compute', () => {
'Subnetworks',
'HealthChecks',
'Networks',
'Rules',
'Snapshots',
];
for (const type of objectTypes) {
Expand All @@ -1151,7 +1150,10 @@ describe('Compute', () => {
let [objects] = await compute[`get${type}`]({
filter: `name eq ${opts.name}.*`,
});
objects = filterExpired(opts, objects);
objects = filterExpired(objects, opts);
if (objects.length === 0) {
return Promise.resolve();
}
console.log(`deleting ${objects.length} ${type}...`);
await Promise.all(
objects.map(async o => {
Expand All @@ -1166,32 +1168,12 @@ describe('Compute', () => {
return awaitResult(object.create(cfg));
}

async function deleteGlobalRules(opts) {
const [rules] = await compute.getRules({
filter: `name eq ${opts.name}.*`,
});
await Promise.all(
filterExpired(opts, rules).map(rule => awaitResult(rule.delete()))
);
}

async function deleteRegionalRules(opts) {
const [rules] = await region.getRules({
filter: `name eq ${opts.name}.*`,
});
return Promise.all(
filterExpired(opts, rules).map(rule => awaitResult(rule.delete()))
);
}

async function deleteServices(opts) {
const [services] = await compute.getServices({
filter: `name eq ${opts.name}.*`,
});
return Promise.all(
filterExpired(opts, services).map(service =>
awaitResult(service.delete())
)
filterExpired(rules, opts).map(rule => awaitResult(rule.delete()))
);
}

Expand Down Expand Up @@ -1221,7 +1203,7 @@ describe('Compute', () => {
https: true,
});
return Promise.all(
filterExpired(opts, healthChecks).map(healthCheck =>
filterExpired(healthChecks, opts).map(healthCheck =>
awaitResult(healthCheck.delete())
)
);
Expand All @@ -1234,11 +1216,8 @@ describe('Compute', () => {
filter: `name eq ${opts.name}.*`,
},
});
if (!resp.items) {
return;
}
return Promise.all(
filterExpired(opts, resp.items)
filterExpired(resp.items, opts)
.map(x => x.name)
.map(deleteUrlMap)
);
Expand Down Expand Up @@ -1270,11 +1249,8 @@ describe('Compute', () => {
filter: `name eq ${opts.name}.*`,
},
});
if (!resp.items) {
return;
}
return Promise.all(
filterExpired(opts, resp.items)
filterExpired(resp.items, opts)
.map(x => x.name)
.map(deleteTargetProxy)
);
Expand Down Expand Up @@ -1306,11 +1282,8 @@ describe('Compute', () => {
filter: `name eq ${opts.name}.*`,
},
});
if (!resp.items) {
return;
}
return Promise.all(
filterExpired(opts, resp.items)
filterExpired(resp.items, opts)
.map(x => x.name)
.map(x => deleteTargetInstance(x))
);
Expand Down Expand Up @@ -1345,10 +1318,7 @@ describe('Compute', () => {
filter: `name eq ${opts.name}.*`,
},
});
if (!resp.items) {
return;
}
const names = filterExpired(opts, resp.items).map(x => x.name);
const names = filterExpired(resp.items, opts).map(x => x.name);
return Promise.all(names.map(x => deleteInstanceTemplate(x)));
}

Expand Down Expand Up @@ -1408,10 +1378,7 @@ describe('Compute', () => {
filter: `name eq ${opts.name}.*`,
},
});
if (!resp.items) {
return;
}
const names = filterExpired(opts, resp.items).map(x => x.name);
const names = filterExpired(resp.items, opts).map(x => x.name);
await Promise.all(names.map(name => deleteInstanceGroupManager(name)));
}

Expand Down Expand Up @@ -1446,7 +1413,8 @@ async function awaitResult(promise) {
await operation.promise();
}

function filterExpired(opts, resources) {
function filterExpired(resources, opts) {
resources = resources || [];
if (opts.expiredOnly) {
return resources.filter(isExpired);
} else {
Expand Down

0 comments on commit ad4797d

Please sign in to comment.