Skip to content

Commit aa8f79b

Browse files
committed
test: add retries to cloud run tests
1 parent a8c4642 commit aa8f79b

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

run/helloworld/test/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ describe('Unit Tests', () => {
2525

2626
it('Service uses the NAME override', async () => {
2727
process.env.NAME = 'Cloud';
28-
const response = await request.get('/').expect(200);
28+
const response = await request.get('/').retry(3).expect(200);
2929
assert.equal(response.text, 'Hello Cloud!');
3030
});
3131

3232
it('Service uses the NAME default', async () => {
3333
process.env.NAME = '';
34-
const response = await request.get('/').expect(200);
34+
const response = await request.get('/').retry(3).expect(200);
3535
assert.equal(response.text, 'Hello World!');
3636
});
3737
});

run/idp-sql/test/app.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ describe('Unit Tests', () => {
2828
});
2929

3030
it('should reject request without JWT token', async () => {
31-
await request.post('/').expect(401);
31+
await request.post('/').retry(3).expect(401);
3232
});
3333

3434
it('should reject request with invalid JWT token', async () => {
3535
await request
3636
.post('/')
3737
.set('Authorization', 'Bearer iam-a-token')
38+
.retry(3)
3839
.expect(403);
3940
});
4041

run/image-processing/test/app.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('Unit Tests', () => {
1919
.post('/')
2020
.type('json')
2121
.send({nomessage: 'invalid'})
22+
.retry(3)
2223
.expect(400);
2324
});
2425

@@ -35,6 +36,7 @@ describe('Unit Tests', () => {
3536
data: 'non-JSON value',
3637
},
3738
})
39+
.retry(3)
3840
.expect(400);
3941
});
4042

@@ -48,6 +50,7 @@ describe('Unit Tests', () => {
4850
data: Buffer.from('{ "json": "value" }').toString('base64'),
4951
},
5052
})
53+
.retry(3)
5154
.expect(400);
5255
});
5356
it('missing just the "name" property', async () => {
@@ -59,6 +62,7 @@ describe('Unit Tests', () => {
5962
data: Buffer.from('{ "name": "value" }').toString('base64'),
6063
},
6164
})
65+
.retry(3)
6266
.expect(400);
6367
});
6468
it('missing just the "bucket" property', async () => {
@@ -70,6 +74,7 @@ describe('Unit Tests', () => {
7074
data: Buffer.from('{ "bucket": "value" }').toString('base64'),
7175
},
7276
})
77+
.retry(3)
7378
.expect(400);
7479
});
7580
});
@@ -88,6 +93,7 @@ describe('Integration Tests', () => {
8893
).toString('base64'),
8994
},
9095
})
96+
.retry(3)
9197
.expect(204);
9298
});
9399
});

run/markdown-preview/editor/test/app.test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Editor unit tests', () => {
2323
it('should successfully load the index page', async () => {
2424
const {app} = require(path.join(__dirname, '..', 'app'));
2525
const request = supertest(app);
26-
await request.get('/').expect(200);
26+
await request.get('/').retry(3).expect(200);
2727
});
2828
});
2929

@@ -53,7 +53,7 @@ describe('Integration tests', () => {
5353
});
5454

5555
it('responds 404 Not Found on "GET /render"', async () => {
56-
await request.get('/render').expect(404);
56+
await request.get('/render').retry(3).expect(404);
5757
});
5858

5959
it('responds 200 OK on "POST /render" with valid JSON', async () => {
@@ -64,6 +64,7 @@ describe('Integration tests', () => {
6464
.type('json')
6565
.set('Accept', 'text/html')
6666
.send({data: 'markdown'})
67+
.retry(3)
6768
.expect(200)
6869
.expect('content-type', 'text/html; charset=utf-8');
6970
});
@@ -74,6 +75,7 @@ describe('Integration tests', () => {
7475
.post('/render')
7576
.type('json')
7677
.send('string: incorrect data type')
78+
.retry(3)
7779
.expect(400);
7880
});
7981
});

run/markdown-preview/renderer/test/app.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('Unit Tests', () => {
4242
.post('/')
4343
.type('text')
4444
.send(markdown)
45+
.retry(3)
4546
.expect(200);
4647
const body = response.text;
4748
assert.equal(body, '<p><strong>markdown text</strong></p>\n');
@@ -53,6 +54,7 @@ describe('Unit Tests', () => {
5354
.post('/')
5455
.type('text')
5556
.send(markdown)
57+
.retry(3)
5658
.expect(200)
5759
.then(res => {
5860
const body = res.text;
@@ -67,6 +69,7 @@ describe('Unit Tests', () => {
6769
.post('/')
6870
.type('text')
6971
.send(markdown)
72+
.retry(3)
7073
.expect(200)
7174
.then(res => {
7275
const body = res.text;

run/pubsub/test/app.test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,25 @@ describe('Unit Tests', () => {
3434

3535
describe('should fail', () => {
3636
it('on a Bad Request with an empty payload', async () => {
37-
await request.post('/').type('json').send('').expect(400);
37+
await request.post('/').type('json').send('').retry(3).expect(400);
3838
});
3939

4040
it('on a Bad Request with an invalid payload', async () => {
4141
await request
4242
.post('/')
4343
.type('json')
4444
.send({nomessage: 'invalid'})
45+
.retry(3)
4546
.expect(400);
4647
});
4748

4849
it('on a Bad Request with an invalid mimetype', async () => {
49-
await request.post('/').type('text').send('{message: true}').expect(400);
50+
await request
51+
.post('/')
52+
.type('text')
53+
.send('{message: true}')
54+
.retry(3)
55+
.expect(400);
5056
});
5157
});
5258

@@ -65,6 +71,7 @@ describe('Unit Tests', () => {
6571
.post('/')
6672
.type('json')
6773
.send({message: true})
74+
.retry(3)
6875
.expect(204)
6976
.expect(() => assert.ok(console.log.calledWith('Hello World!')));
7077
});
@@ -77,6 +84,7 @@ describe('Unit Tests', () => {
7784
.post('/')
7885
.type('json')
7986
.send({message: {data}})
87+
.retry(3)
8088
.expect(204)
8189
.expect(() => assert.ok(console.log.calledWith(`Hello ${name}!`)));
8290
});

run/system-package/test/app.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('Unit Tests', () => {
2828
await request
2929
.get('/diagram.png')
3030
.type('text')
31+
.retry(3)
3132
.expect(400)
3233
.expect('Content-Type', errorContentType)
3334
.expect(res => {
@@ -42,6 +43,7 @@ describe('Unit Tests', () => {
4243
.get('/diagram.png')
4344
.type('text')
4445
.query({dot: ''})
46+
.retry(3)
4547
.expect(400)
4648
.expect('Content-Type', errorContentType)
4749
.expect(res => {
@@ -56,6 +58,7 @@ describe('Unit Tests', () => {
5658
.get('/diagram.png')
5759
.type('text')
5860
.query({dot: 'digraph'})
61+
.retry(3)
5962
.expect(400)
6063
.expect('Content-Type', errorContentType)
6164
.expect(res => {
@@ -72,6 +75,7 @@ describe('Unit Tests', () => {
7275
.get('/diagram.png')
7376
.type('text')
7477
.query({dot: 'digraph G { A -> {B, C, D} -> {F} }'})
78+
.retry(3)
7579
.expect(200)
7680
.expect('Content-Type', 'image/png')
7781
.expect('Cache-Control', 'public, max-age=86400');

0 commit comments

Comments
 (0)