Skip to content

Commit a5068d1

Browse files
committed
Tweaks automated tests to reduce spurious failures in CI
1 parent ade98dd commit a5068d1

File tree

6 files changed

+41
-38
lines changed

6 files changed

+41
-38
lines changed

spec/account.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports.shouldCreateDeleteAndReadAccounts = function () {
111111
});
112112

113113
it('deletes a user', async function () {
114-
this.timeout(15_000);
114+
this.timeout(60_000);
115115
const params = { username: this.usernameAccount2, contactURL: '[email protected]' };
116116
this.user2 = await this.accountMgr.createUser(params, new Set());
117117

spec/armadietto/oauth_spec.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const store = {
3535
};
3636

3737
const sandbox = chai.spy.sandbox();
38-
describe('OAuth', async () => {
38+
describe('OAuth', async function () {
3939
before((done) => {
40-
(async () => {
40+
(async function () {
4141
this._server = new Armadietto({
4242
store,
4343
http: { port: 4567 },
@@ -49,13 +49,13 @@ describe('OAuth', async () => {
4949
});
5050

5151
after((done) => {
52-
(async () => {
52+
(async function () {
5353
await this._server.stop();
5454
done();
5555
})();
5656
});
5757

58-
beforeEach(() => {
58+
beforeEach(function () {
5959
this.auth_params = {
6060
username: 'zebcoe',
6161
password: 'locog',
@@ -69,93 +69,94 @@ describe('OAuth', async () => {
6969
sandbox.on(store, ['authorize', 'authenticate']);
7070
});
7171

72-
afterEach(() => {
72+
afterEach(function () {
7373
sandbox.restore();
7474
});
7575

76-
describe('with invalid client input', () => {
77-
beforeEach(() => {
78-
delete this.auth_params.state;
76+
describe('with invalid client input', function () {
77+
beforeEach(function () {
78+
delete this.auth_params?.state;
79+
this.timeout(60_000);
7980
});
8081

81-
it('returns an error if redirect_uri is missing', async () => {
82+
it('returns an error if redirect_uri is missing', async function () {
8283
delete this.auth_params.redirect_uri;
8384
const res = await get('/oauth/me', this.auth_params);
8485
expect(res).to.have.status(400);
8586
expect(res.text).to.have.been.equal('error=invalid_request&error_description=Required%20parameter%20%22redirect_uri%22%20is%20missing');
8687
});
8788

88-
it('returns an error if client_id is missing', async () => {
89+
it('returns an error if client_id is missing', async function () {
8990
delete this.auth_params.client_id;
9091
const res = await get('/oauth/me', this.auth_params);
9192
expect(res).to.redirectTo('http://example.com/cb#error=invalid_request&error_description=Required%20parameter%20%22client_id%22%20is%20missing');
9293
});
9394

94-
it('returns an error if response_type is missing', async () => {
95+
it('returns an error if response_type is missing', async function () {
9596
delete this.auth_params.response_type;
9697
const res = await get('/oauth/me', this.auth_params);
9798
expect(res).to.redirectTo('http://example.com/cb#error=invalid_request&error_description=Required%20parameter%20%22response_type%22%20is%20missing');
9899
});
99100

100-
it('returns an error if response_type is not recognized', async () => {
101+
it('returns an error if response_type is not recognized', async function () {
101102
this.auth_params.response_type = 'wrong';
102103
const res = await get('/oauth/me', this.auth_params);
103104
expect(res).to.redirectTo('http://example.com/cb#error=unsupported_response_type&error_description=Response%20type%20%22wrong%22%20is%20not%20supported');
104105
});
105106

106-
it('returns an error if scope is missing', async () => {
107+
it('returns an error if scope is missing', async function () {
107108
delete this.auth_params.scope;
108109
const res = await get('/oauth/me', this.auth_params);
109110
expect(res).to.redirectTo('http://example.com/cb#error=invalid_scope&error_description=Parameter%20%22scope%22%20is%20invalid');
110111
});
111112

112-
it('returns an error if username is missing', async () => {
113+
it('returns an error if username is missing', async function () {
113114
delete this.auth_params.username;
114115
const res = await post('/oauth', this.auth_params);
115116
expect(res).to.have.status(400);
116117
});
117118
});
118119

119-
describe('with valid login credentials', async () => {
120-
describe('without explicit read/write permissions', async () => {
121-
it('authorizes the client to read and write', async () => {
120+
describe('with valid login credentials', async function () {
121+
describe('without explicit read/write permissions', async function () {
122+
it('authorizes the client to read and write', async function () {
122123
await post('/oauth', this.auth_params);
123124
expect(store.authorize).to.be.called.with('the_client_id', 'zebcoe', { the_scope: ['r', 'w'] });
124125
});
125126
});
126127

127-
describe('with explicit read permission', async () => {
128-
it('authorizes the client to read', async () => {
128+
describe('with explicit read permission', async function () {
129+
it('authorizes the client to read', async function () {
129130
this.auth_params.scope = 'the_scope:r';
130131
await post('/oauth', this.auth_params);
131132
expect(store.authorize).to.be.called.with('the_client_id', 'zebcoe', { the_scope: ['r'] });
132133
});
133134
});
134135

135-
describe('with explicit read/write permission', async () => {
136-
it('authorizes the client to read and write', async () => {
136+
describe('with explicit read/write permission', async function () {
137+
it('authorizes the client to read and write', async function () {
137138
this.auth_params.scope = 'the_scope:rw';
138139
await post('/oauth', this.auth_params);
139140
expect(store.authorize).to.be.called.with('the_client_id', 'zebcoe', { the_scope: ['r', 'w'] });
140141
});
141142
});
142143

143-
it('redirects with an access token', async () => {
144+
it('redirects with an access token', async function () {
144145
const res = await post('/oauth', this.auth_params);
145146
expect(res).to.redirectTo('http://example.com/cb#access_token=a_token&token_type=bearer&state=the_state');
146147
});
147148
});
148149

149-
describe('with invalid login credentials', async () => {
150-
it('does not authorize the client', async () => {
150+
describe('with invalid login credentials', async function () {
151+
it('does not authorize the client', async function () {
151152
store.authenticate = (params) => {
152153
throw new Error();
153154
};
154155
await post('/oauth', this.auth_params);
155156
expect(store.authorize).to.be.called.exactly(0);
156157
});
157158

158-
it('returns a 401 response with the login form', async () => {
159+
it('returns a 401 response with the login form', async function () {
159160
store.authenticate = (params) => {
160161
throw new Error();
161162
};

spec/modular/m_oauth.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ describe('OAuth (modular)', function () {
120120
scope: 'the_scope'
121121
// no state
122122
};
123+
this.timeout(60_000);
123124
});
124125

125126
it('returns an error if redirect_uri is missing', async function () {

spec/oauth.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ exports.shouldImplementOAuth = function () {
2121
scope: 'the_scope'
2222
// no state
2323
};
24+
this.timeout(60_000);
2425
});
2526

2627
it('returns an error if redirect_uri is missing', async function () {

spec/store_handler.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const LIST_DIR_NAME = 'stuff-' + Math.round(Math.random() * Number.MAX_SAFE_INTE
2020

2121
module.exports.shouldStoreStreams = function () {
2222
before(async function () {
23-
this.timeout(15_000);
23+
this.timeout(60_000);
2424

25-
const usernameStore = 'automated-test-' + Math.round(Math.random() * Number.MAX_SAFE_INTEGER);
25+
const usernameStore = ('automated-test-' + Math.round(Math.random() * Number.MAX_SAFE_INTEGER)).slice(0, 29);
2626
const user = await this.store.createUser({ username: usernameStore, contactURL: '[email protected]' }, new Set());
2727
this.userIdStore = user.username;
2828
});
@@ -33,7 +33,7 @@ module.exports.shouldStoreStreams = function () {
3333
});
3434

3535
describe('upsertAdminBlob & readAdminBlob', function () {
36-
this.timeout(30_000);
36+
this.timeout(60_000);
3737

3838
it('should store and retrieve blobs', async function () {
3939
const relativePath = path.join(ADMIN_INVITE_DIR_NAME, 'mailto%3Atestname%40testhost.org.yaml');
@@ -49,7 +49,7 @@ module.exports.shouldStoreStreams = function () {
4949
});
5050

5151
describe('metadataAdminBlob', function () {
52-
this.timeout(30_000);
52+
this.timeout(60_000);
5353

5454
it('should retrieve metadata', async function () {
5555
const relativePath = path.join(ADMIN_INVITE_DIR_NAME, 'mailto%3Asomename%40somehost.edu.yaml');
@@ -69,7 +69,7 @@ module.exports.shouldStoreStreams = function () {
6969
});
7070

7171
describe('deleteAdminBlob', function () {
72-
this.timeout(30_000);
72+
this.timeout(60_000);
7373

7474
it('should delete blob', async function () {
7575
const relativePath = path.join(ADMIN_INVITE_DIR_NAME, 'mailto%3Asomename%40somehost.edu.yaml');
@@ -122,7 +122,7 @@ module.exports.shouldStoreStreams = function () {
122122
});
123123

124124
describe('GET', function () {
125-
this.timeout(30_000);
125+
this.timeout(60_000);
126126

127127
describe('for files', function () {
128128
describe('unversioned', function () {
@@ -383,11 +383,11 @@ module.exports.shouldStoreStreams = function () {
383383
expect(folder.items['yellow-red'].ETag).to.equal(stripQuotes(putRes1.get('ETag')));
384384
expect(folder.items['yellow-red']['Content-Type']).to.equal('text/csv');
385385
expect(folder.items['yellow-red']['Content-Length']).to.equal(content1.length);
386-
expect(Date.now() - new Date(folder.items['yellow-red']['Last-Modified'])).to.be.lessThan(20_000);
386+
expect(Date.now() - new Date(folder.items['yellow-red']['Last-Modified'])).to.be.lessThan(60_000);
387387
expect(folder.items['blue-green'].ETag).to.equal(stripQuotes(putRes2.get('ETag')));
388388
expect(folder.items['blue-green']['Content-Type']).to.equal('text/n3');
389389
expect(folder.items['blue-green']['Content-Length']).to.equal(content2.length);
390-
expect(Date.now() - new Date(folder.items['blue-green']['Last-Modified'])).to.be.lessThan(15_000);
390+
expect(Date.now() - new Date(folder.items['blue-green']['Last-Modified'])).to.be.lessThan(60_000);
391391
expect(folder.items['subfolder/'].ETag).to.match(/^.{6,128}$/);
392392

393393
const [_subfolderReq, subfolderRes] = await callMiddleware(this.handler, {
@@ -484,7 +484,7 @@ module.exports.shouldStoreStreams = function () {
484484
});
485485

486486
describe('PUT', function () {
487-
this.timeout(30_000);
487+
this.timeout(60_000);
488488

489489
describe('unversioned', function () {
490490
it('does not create a file for a bad user name', async function () {
@@ -1334,7 +1334,7 @@ module.exports.shouldStoreStreams = function () {
13341334
});
13351335

13361336
describe('DELETE', function () {
1337-
this.timeout(30_000);
1337+
this.timeout(60_000);
13381338

13391339
describe('unversioned', function () {
13401340
it('should return Not Found for nonexistent user', async function () {

spec/store_handlers/S3_store_handler.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const { shouldCreateDeleteAndReadAccounts } = require('../account.spec');
1111

1212
describe('S3 store router', function () {
1313
before(function () {
14-
this.timeout(15_000);
14+
this.timeout(60_000);
1515
configureLogger({ stdout: ['notice'], log_dir: './test-log', log_files: ['debug'] });
16-
this.USER_NAME_SUFFIX = '-java.extraordinary.org';
16+
this.USER_NAME_SUFFIX = '-java.extraordinary.test';
1717
// If the environment variables aren't set, tests are run using a shared public account on play.min.io
1818
console.info(`creating s3storeHandler with endpoint “${process.env.S3_ENDPOINT}”, accessKey “${process.env.S3_ACCESS_KEY}”, & region “${process.env.S3_REGION}”`);
1919
this.handler = s3storeHandler({ endPoint: process.env.S3_ENDPOINT, accessKey: process.env.S3_ACCESS_KEY, secretKey: process.env.S3_SECRET_KEY, region: process.env.S3_REGION || 'us-east-1', userNameSuffix: this.USER_NAME_SUFFIX });

0 commit comments

Comments
 (0)