Skip to content

Commit 63e6cc3

Browse files
committed
make failing tests more linear in a parallel world
1 parent 82162c2 commit 63e6cc3

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

compute/test/createInstanceReplicatedBootDisk.test.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,28 +118,16 @@ describe('Create compute instance with replicated boot disk', async () => {
118118
let projectId;
119119
let diskSnapshotLink;
120120

121-
before(async () => {
121+
it('should create an instance with replicated boot disk', async () => {
122+
123+
// before
122124
const instancesClient = new computeLib.InstancesClient();
123125
projectId = await instancesClient.getProjectId();
124126
diskSnapshotLink = `projects/${projectId}/global/snapshots/${snapshotName}`;
125127

126128
await createDisk(projectId, zone1, diskName);
127129
await createDiskSnapshot(projectId, zone1, diskName, snapshotName);
128-
});
129130

130-
after(async () => {
131-
// Cleanup resources
132-
const instances = await getStaleVMInstances();
133-
await Promise.all(
134-
instances.map(instance =>
135-
deleteInstance(instance.zone, instance.instanceName)
136-
)
137-
);
138-
await deleteDiskSnapshot(projectId, snapshotName);
139-
await deleteDisk(projectId, zone1, diskName);
140-
});
141-
142-
it('should create an instance with replicated boot disk', () => {
143131
const response = execSync(
144132
`node ./instances/create-start-instance/createInstanceReplicatedBootDisk.js ${zone1} ${zone2} ${vmName} ${diskSnapshotLink}`,
145133
{
@@ -152,5 +140,15 @@ describe('Create compute instance with replicated boot disk', async () => {
152140
`Instance: ${vmName} with replicated boot disk created.`
153141
)
154142
);
143+
144+
// after Cleanup resources
145+
const instances = await getStaleVMInstances();
146+
await Promise.all(
147+
instances.map(instance =>
148+
deleteInstance(instance.zone, instance.instanceName)
149+
)
150+
);
151+
await deleteDiskSnapshot(projectId, snapshotName);
152+
await deleteDisk(projectId, zone1, diskName);
155153
});
156154
});

compute/test/replicatedDisk.test.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,11 @@ describe('Create compute regional replicated disk', async () => {
5757
const zone2 = `${region}-b`;
5858
let projectId;
5959

60-
before(async () => {
60+
61+
it('should create a regional replicated disk and attach to vm', async () => {
6162
const instancesClient = new computeLib.InstancesClient();
6263
projectId = await instancesClient.getProjectId();
63-
});
64-
65-
after(async () => {
66-
// Cleanup resources
67-
execSync(`node ./deleteInstance.js ${projectId} ${zone1} ${vmName}`, {
68-
cwd,
69-
});
70-
await deleteDisk(projectId, region, diskName);
71-
});
7264

73-
it('should create a regional replicated disk', () => {
7465
const response = execSync(
7566
`node ./disks/createRegionalReplicatedDisk.js ${diskName} ${region} ${zone1} ${zone2}`,
7667
{
@@ -79,9 +70,7 @@ describe('Create compute regional replicated disk', async () => {
7970
);
8071

8172
assert(response.includes(`Regional replicated disk: ${diskName} created.`));
82-
});
8373

84-
it('should attach replicated disk to vm', () => {
8574
// Create VM, where replicated disk will be attached.
8675
execSync(
8776
`node ./createInstance.js ${projectId} ${zone1} ${vmName} e2-small`,
@@ -90,17 +79,23 @@ describe('Create compute regional replicated disk', async () => {
9079
}
9180
);
9281

93-
const response = execSync(
82+
const responseAttach = execSync(
9483
`node ./disks/attachRegionalDisk.js ${diskName} ${region} ${vmName} ${zone1}`,
9584
{
9685
cwd,
9786
}
9887
);
9988

10089
assert(
101-
response.includes(
90+
responseAttach.includes(
10291
`Replicated disk: ${diskName} attached to VM: ${vmName}.`
10392
)
10493
);
94+
95+
// Cleanup resources
96+
execSync(`node ./deleteInstance.js ${projectId} ${zone1} ${vmName}`, {
97+
cwd,
98+
});
99+
await deleteDisk(projectId, region, diskName);
105100
});
106101
});

0 commit comments

Comments
 (0)