Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 7be90ee

Browse files
authored
fix: Wait for long running operation on flakey test (#1141)
* wait for long running operation on flakey test. * fix: Wait for long running operation on flakey test
1 parent a7079bc commit 7be90ee

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

system-test/cluster.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ describe('Cluster', () => {
3636
compareValues: SetClusterMetadataOptions,
3737
isConfigDefined: boolean
3838
): Promise<void> {
39-
// const cluster: Cluster = instance.cluster(clusterId);
40-
console.log(`Cluster Id: ${cluster.id}`);
4139
const metadata = await cluster.getMetadata({});
4240
const {clusterConfig, serveNodes} = metadata[0];
4341
assert.strictEqual(serveNodes, compareValues.nodes);
@@ -68,7 +66,6 @@ describe('Cluster', () => {
6866
time_created: Date.now(),
6967
},
7068
});
71-
console.log(`Test Instance Id: ${instanceId}`);
7269
await operation.promise();
7370
}
7471
async function createStandardNewInstance(
@@ -107,10 +104,11 @@ describe('Cluster', () => {
107104
it('should create an instance and then create a cluster for manual scaling', async () => {
108105
const clusterId2: string = generateId('cluster');
109106
const cluster2 = instance.cluster(clusterId2);
110-
await cluster2.create({
107+
const [, operation] = await cluster2.create({
111108
location: 'us-west1-c',
112109
nodes: 3,
113110
});
111+
await operation.promise();
114112
await checkMetadata(cluster2, {nodes: 3}, false);
115113
});
116114
describe('Using an incorrect configuration', () => {
@@ -121,9 +119,10 @@ describe('Cluster', () => {
121119
});
122120
it('should throw an error when providing no cluster configuration', async () => {
123121
try {
124-
await cluster2.create({
122+
const [, operation] = await cluster2.create({
125123
location: 'us-west1-c',
126124
});
125+
await operation.promise();
127126
assert.fail();
128127
} catch (e) {
129128
assert.ok(isValidationError(e));
@@ -132,11 +131,12 @@ describe('Cluster', () => {
132131
});
133132
it('should throw an error when providing manual and autoscaling configurations', async () => {
134133
try {
135-
await cluster2.create({
134+
const [, operation] = await cluster2.create({
136135
location: 'us-west1-c',
137136
nodes: 2,
138137
minServeNodes: 3,
139138
});
139+
await operation.promise();
140140
assert.fail();
141141
} catch (e) {
142142
assert.ok(isValidationError(e));
@@ -145,11 +145,12 @@ describe('Cluster', () => {
145145
});
146146
it('should throw an error when missing all autoscaling configurations', async () => {
147147
try {
148-
await cluster2.create({
148+
const [, operation] = await cluster2.create({
149149
location: 'us-west1-c',
150150
minServeNodes: 3,
151151
cpuUtilizationPercent: 51,
152152
});
153+
await operation.promise();
153154
assert.fail();
154155
} catch (e) {
155156
assert.ok(isValidationError(e));
@@ -189,7 +190,8 @@ describe('Cluster', () => {
189190
await createStandardNewInstance(clusterId, 2);
190191
const clusterId2: string = generateId('cluster');
191192
const cluster: Cluster = instance.cluster(clusterId2);
192-
await cluster.create(createClusterOptions);
193+
const [, operation] = await cluster.create(createClusterOptions);
194+
await operation.promise();
193195
await checkMetadata(
194196
cluster,
195197
{
@@ -214,7 +216,8 @@ describe('Cluster', () => {
214216

215217
it('should change nodes for manual scaling', async () => {
216218
const updateNodes = 5;
217-
await cluster.setMetadata({nodes: updateNodes});
219+
const [operation] = await cluster.setMetadata({nodes: updateNodes});
220+
await operation.promise();
218221
await checkMetadata(
219222
cluster,
220223
{
@@ -227,11 +230,12 @@ describe('Cluster', () => {
227230
const minServeNodes = 3;
228231
const maxServeNodes = 4;
229232
const cpuUtilizationPercent = 50;
230-
await cluster.setMetadata({
233+
const [operation] = await cluster.setMetadata({
231234
minServeNodes,
232235
maxServeNodes,
233236
cpuUtilizationPercent,
234237
});
238+
await operation.promise();
235239
await checkMetadata(
236240
cluster,
237241
{
@@ -246,7 +250,8 @@ describe('Cluster', () => {
246250
describe('Using an incorrect configuration', () => {
247251
it('should throw an error when providing no cluster configuration', async () => {
248252
try {
249-
await cluster.setMetadata({});
253+
const [operation] = await cluster.setMetadata({});
254+
await operation.promise();
250255
assert.fail();
251256
} catch (e) {
252257
assert.ok(isValidationError(e));
@@ -255,10 +260,11 @@ describe('Cluster', () => {
255260
});
256261
it('should throw an error when providing manual and autoscaling configurations', async () => {
257262
try {
258-
await cluster.setMetadata({
263+
const [operation] = await cluster.setMetadata({
259264
nodes: 2,
260265
minServeNodes: 3,
261266
});
267+
await operation.promise();
262268
assert.fail();
263269
} catch (e) {
264270
assert.ok(isValidationError(e));
@@ -267,10 +273,11 @@ describe('Cluster', () => {
267273
});
268274
it('should throw an error when missing some autoscaling configurations', async () => {
269275
try {
270-
await cluster.setMetadata({
276+
const [operation] = await cluster.setMetadata({
271277
minServeNodes: 3,
272278
cpuUtilizationPercent: 51,
273279
});
280+
await operation.promise();
274281
assert.fail();
275282
} catch (e) {
276283
assert.ok(isValidationError(e));
@@ -302,9 +309,10 @@ describe('Cluster', () => {
302309

303310
it('should change cluster to manual scaling', async () => {
304311
const updateNodes = 5;
305-
await cluster.setMetadata({
312+
const [operation] = await cluster.setMetadata({
306313
nodes: updateNodes,
307314
});
315+
await operation.promise();
308316
await checkMetadata(
309317
cluster,
310318
{
@@ -320,11 +328,12 @@ describe('Cluster', () => {
320328
assert.notEqual(minServeNodes, newMinServeNodes);
321329
assert.notEqual(maxServeNodes, newMaxServeNodes);
322330
assert.notEqual(cpuUtilizationPercent, newCpuUtilizationPercent);
323-
await cluster.setMetadata({
331+
const [operation] = await cluster.setMetadata({
324332
minServeNodes: newMinServeNodes,
325333
maxServeNodes: newMaxServeNodes,
326334
cpuUtilizationPercent: newCpuUtilizationPercent,
327335
});
336+
await operation.promise();
328337
await checkMetadata(
329338
cluster,
330339
{

0 commit comments

Comments
 (0)