Skip to content

Commit 1666c3e

Browse files
authored
[WIP] Enable test suite to be randomized (#7265)
* initial run * Update ParseGraphQLServer.spec.js * temporarily enable reporter * Bump retry limit * fix undefined database * try to catch error * Handle LiveQueryServers * Update Config.js * fast-fail false * Remove usage of AppCache * oops * Update contributing guide * enable debugger, try network retry attempt 1 * Fix ldap unbinding * move non specs to support * add missing mock adapter * fix Parse.Push * RestController should match batch.spec.js * Remove request attempt limit * handle index.spec.js * Update CHANGELOG.md * Handle error: tuple concurrently updated * test transactions * Clear RedisCache after every test * LoggerController.spec.js * Update schemas.spec.js * finally fix transactions * fix geopoint deadlock * transaction with clean database * batch.spec.js
1 parent 9563793 commit 1666c3e

36 files changed

+686
-698
lines changed

.github/workflows/ci.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
jobs:
1414
check-ci:
1515
name: CI Self-Check
16-
timeout-minutes: 30
16+
timeout-minutes: 15
1717
runs-on: ubuntu-18.04
1818
steps:
1919
- uses: actions/checkout@v2
@@ -34,7 +34,7 @@ jobs:
3434
run: npm run ci:check
3535
check-lint:
3636
name: Lint
37-
timeout-minutes: 30
37+
timeout-minutes: 15
3838
runs-on: ubuntu-18.04
3939
steps:
4040
- uses: actions/checkout@v2
@@ -97,8 +97,9 @@ jobs:
9797
MONGODB_TOPOLOGY: standalone
9898
MONGODB_STORAGE_ENGINE: wiredTiger
9999
NODE_VERSION: 15.11.0
100+
fail-fast: false
100101
name: ${{ matrix.name }}
101-
timeout-minutes: 30
102+
timeout-minutes: 15
102103
runs-on: ubuntu-18.04
103104
services:
104105
redis:
@@ -145,8 +146,9 @@ jobs:
145146
POSTGRES_IMAGE: postgis/postgis:12-3.0
146147
- name: Postgres 13, Postgis 3.1
147148
POSTGRES_IMAGE: postgis/postgis:13-3.1
149+
fail-fast: false
148150
name: ${{ matrix.name }}
149-
timeout-minutes: 30
151+
timeout-minutes: 15
150152
runs-on: ubuntu-18.04
151153
services:
152154
redis:

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ ___
114114
- Allow Cloud Validator `options` to be async (dblythy) [#7155](https://github.com/parse-community/parse-server/pull/7155)
115115
- Optimize queries on classes with pointer permissions (Pedro Diaz) [#7061](https://github.com/parse-community/parse-server/pull/7061)
116116
- Test Parse Server continuously against all relevant Postgres versions (minor versions), added Postgres compatibility table to Parse Server docs (Corey Baker) [#7176](https://github.com/parse-community/parse-server/pull/7176)
117+
- Randomize test suite (Diamond Lewis) [#7265](https://github.com/parse-community/parse-server/pull/7265)
118+
- LDAP: Properly unbind client on group search error (Diamond Lewis) [#7265](https://github.com/parse-community/parse-server/pull/7265)
117119
___
118120
## 4.5.0
119121
[Full Changelog](https://github.com/parse-community/parse-server/compare/4.4.0...4.5.0)

CONTRIBUTING.md

+9
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ Once you have babel running in watch mode, you can start making changes to parse
8484
* All the tests should point to sources in the `lib/` folder.
8585
* The `lib/` folder is produced by `babel` using either the `npm run build`, `npm run watch`, or the `npm run prepare` step.
8686
* The `npm run prepare` step is automatically invoked when your package depends on forked parse-server installed via git for example using `npm install --save git+https://github.com/[username]/parse-server#[branch/commit]`.
87+
* The tests are run against a single server instance. You can change the server configurations using `await reconfigureServer({ ... some configuration })` found in `spec/helper.js`.
88+
* The tests are ran at random.
89+
* Caches and Configurations are reset after every test.
90+
* Users are logged out after every test.
91+
* Cloud Code hooks are removed after every test.
92+
* Database is deleted after every test (indexes are not removed for speed)
93+
* Tests are located in the `spec` folder
94+
* For better test reporting enable `PARSE_SERVER_LOG_LEVEL=debug`
8795

8896
### Troubleshooting
8997

@@ -108,6 +116,7 @@ Once you have babel running in watch mode, you can start making changes to parse
108116
* Run the tests for the whole project to make sure the code passes all tests. This can be done by running the test command for a single file but removing the test file argument. The results can be seen at *<PROJECT_ROOT>/coverage/lcov-report/index.html*.
109117
* Lint your code by running `npm run lint` to make sure the code is not going to be rejected by the CI.
110118
* **Do not** publish the *lib* folder.
119+
* Mocks belong in the `spec/support` folder.
111120
* Please consider if any changes to the [docs](http://docs.parseplatform.org) are needed or add additional sections in the case of an enhancement or feature.
112121

113122
### Test against Postgres

spec/AdapterLoader.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Config = require('../lib/Config');
66

77
describe('AdapterLoader', () => {
88
it('should instantiate an adapter from string in object', done => {
9-
const adapterPath = require('path').resolve('./spec/MockAdapter');
9+
const adapterPath = require('path').resolve('./spec/support/MockAdapter');
1010

1111
const adapter = loadAdapter({
1212
adapter: adapterPath,
@@ -23,7 +23,7 @@ describe('AdapterLoader', () => {
2323
});
2424

2525
it('should instantiate an adapter from string', done => {
26-
const adapterPath = require('path').resolve('./spec/MockAdapter');
26+
const adapterPath = require('path').resolve('./spec/support/MockAdapter');
2727
const adapter = loadAdapter(adapterPath);
2828

2929
expect(adapter instanceof Object).toBe(true);
@@ -119,7 +119,7 @@ describe('AdapterLoader', () => {
119119
});
120120

121121
it('should load custom push adapter from string (#3544)', done => {
122-
const adapterPath = require('path').resolve('./spec/MockPushAdapter');
122+
const adapterPath = require('path').resolve('./spec/support/MockPushAdapter');
123123
const options = {
124124
ios: {
125125
bundleId: 'bundle.id',

spec/CLI.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ describe('execution', () => {
227227
'test',
228228
'--databaseURI',
229229
'mongodb://localhost/test',
230+
'--port',
231+
'1339',
230232
]);
231233
childProcess.stdout.on('data', data => {
232234
data = data.toString();
@@ -247,6 +249,8 @@ describe('execution', () => {
247249
'test',
248250
'--databaseURI',
249251
'mongodb://localhost/test',
252+
'--port',
253+
'1340',
250254
'--mountGraphQL',
251255
]);
252256
let output = '';
@@ -271,6 +275,8 @@ describe('execution', () => {
271275
'test',
272276
'--databaseURI',
273277
'mongodb://localhost/test',
278+
'--port',
279+
'1341',
274280
'--mountGraphQL',
275281
'--mountPlayground',
276282
]);

spec/FilesController.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ describe('FilesController', () => {
8080
expect(typeof error).toBe('object');
8181
expect(error.message.indexOf('biscuit')).toBe(13);
8282
expect(error.code).toBe(Parse.Error.INVALID_FILE_NAME);
83+
mockAdapter.validateFilename = () => {
84+
return null;
85+
};
8386
done();
8487
});
8588

spec/GridFSBucketStorageAdapter.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const GridFSBucketAdapter = require('../lib/Adapters/Files/GridFSBucketAdapter')
44
const { randomString } = require('../lib/cryptoUtils');
55
const databaseURI = 'mongodb://localhost:27017/parse';
66
const request = require('../lib/request');
7-
const Config = require('../lib/Config');
87

98
async function expectMissingFile(gfsAdapter, name) {
109
try {
@@ -395,8 +394,9 @@ describe_only_db('mongo')('GridFSBucket and GridStore interop', () => {
395394
});
396395

397396
it('should handle getMetadata error', async () => {
398-
const config = Config.get('test');
399-
config.filesController.getMetadata = () => Promise.reject();
397+
const gfsAdapter = new GridFSBucketAdapter(databaseURI);
398+
await reconfigureServer({ filesAdapter: gfsAdapter });
399+
gfsAdapter.getMetadata = () => Promise.reject();
400400

401401
const headers = {
402402
'X-Parse-Application-Id': 'test',

0 commit comments

Comments
 (0)