ci: Fix invalid MongoDB version ranges for tests (#9474)
This commit is contained in:
@@ -263,9 +263,7 @@ If your pull request introduces a change that may affect the storage or retrieva
|
|||||||
* If your feature is intended to work with MongoDB and PostgreSQL, you can include or exclude tests more granularly with:
|
* If your feature is intended to work with MongoDB and PostgreSQL, you can include or exclude tests more granularly with:
|
||||||
|
|
||||||
- `it_only_mongodb_version('>=4.4')` // will test with any version of Postgres but only with version >=4.4 of MongoDB; accepts semver notation to specify a version range
|
- `it_only_mongodb_version('>=4.4')` // will test with any version of Postgres but only with version >=4.4 of MongoDB; accepts semver notation to specify a version range
|
||||||
- `it_exclude_mongodb_version('<4.4')` // will test with any version of Postgres and MongoDB, excluding version <4.4 of MongoDB; accepts semver notation to specify a version range
|
|
||||||
- `it_only_postgres_version('>=13')` // will test with any version of Mongo but only with version >=13 of Postgres; accepts semver notation to specify a version range
|
- `it_only_postgres_version('>=13')` // will test with any version of Mongo but only with version >=13 of Postgres; accepts semver notation to specify a version range
|
||||||
- `it_exclude_postgres_version('<13')` // will test with any version of Postgres and MongoDB, excluding version <13 of Postgres; accepts semver notation to specify a version range
|
|
||||||
|
|
||||||
#### Postgres with Docker
|
#### Postgres with Docker
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@
|
|||||||
"test:mongodb:5.3.2": "npm run test:mongodb --dbversion=5.3.2",
|
"test:mongodb:5.3.2": "npm run test:mongodb --dbversion=5.3.2",
|
||||||
"test:mongodb:6.0.2": "npm run test:mongodb --dbversion=6.0.2",
|
"test:mongodb:6.0.2": "npm run test:mongodb --dbversion=6.0.2",
|
||||||
"test:mongodb:7.0.1": "npm run test:mongodb --dbversion=7.0.1",
|
"test:mongodb:7.0.1": "npm run test:mongodb --dbversion=7.0.1",
|
||||||
|
"test:mongodb:8.0.3": "npm run test:mongodb --dbversion=8.0.3",
|
||||||
"test:postgres:testonly": "cross-env PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly",
|
"test:postgres:testonly": "cross-env PARSE_SERVER_TEST_DB=postgres PARSE_SERVER_TEST_DATABASE_URI=postgres://postgres:password@localhost:5432/parse_server_postgres_adapter_test_database npm run testonly",
|
||||||
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
|
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} mongodb-runner start -t ${MONGODB_TOPOLOGY} --version ${MONGODB_VERSION} -- --port 27017",
|
||||||
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
|
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.3.2} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine",
|
||||||
|
|||||||
@@ -22,11 +22,8 @@
|
|||||||
"it_only_postgres_version": true,
|
"it_only_postgres_version": true,
|
||||||
"it_only_node_version": true,
|
"it_only_node_version": true,
|
||||||
"fit_only_mongodb_version": true,
|
"fit_only_mongodb_version": true,
|
||||||
|
"fit_only_postgres_version": true,
|
||||||
"fit_only_node_version": true,
|
"fit_only_node_version": true,
|
||||||
"it_exclude_mongodb_version": true,
|
|
||||||
"it_exclude_postgres_version": true,
|
|
||||||
"fit_exclude_mongodb_version": true,
|
|
||||||
"fit_exclude_node_version": true,
|
|
||||||
"it_exclude_dbs": true,
|
"it_exclude_dbs": true,
|
||||||
"fit_exclude_dbs": true,
|
"fit_exclude_dbs": true,
|
||||||
"describe_only_db": true,
|
"describe_only_db": true,
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
|||||||
await expectAsync(adapter.getClass('UnknownClass')).toBeRejectedWith(undefined);
|
await expectAsync(adapter.getClass('UnknownClass')).toBeRejectedWith(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_mongodb_version('<5.1>=6')('should use index for caseInsensitive query', async () => {
|
it_only_mongodb_version('<5.1 || >=6')('should use index for caseInsensitive query', async () => {
|
||||||
const user = new Parse.User();
|
const user = new Parse.User();
|
||||||
user.set('username', 'Bugs');
|
user.set('username', 'Bugs');
|
||||||
user.set('password', 'Bunny');
|
user.set('password', 'Bunny');
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
|
|||||||
await TestUtils.destroyAllDataPermanently(false);
|
await TestUtils.destroyAllDataPermanently(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_mongodb_version('<5.1>=6')('query find with hint string', async () => {
|
it_only_mongodb_version('<5.1 || >=6 <8')('query find with hint string', async () => {
|
||||||
const object = new TestObject();
|
const object = new TestObject();
|
||||||
await object.save();
|
await object.save();
|
||||||
|
|
||||||
@@ -50,7 +50,19 @@ describe_only_db('mongo')('Parse.Query hint', () => {
|
|||||||
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.indexName).toBe('_id_');
|
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.indexName).toBe('_id_');
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_mongodb_version('<5.1>=6')('query find with hint object', async () => {
|
it_only_mongodb_version('>=8')('query find with hint string', async () => {
|
||||||
|
const object = new TestObject();
|
||||||
|
await object.save();
|
||||||
|
|
||||||
|
const collection = await config.database.adapter._adaptiveCollection('TestObject');
|
||||||
|
let explain = await collection._rawFind({ _id: object.id }, { explain: true });
|
||||||
|
expect(explain.queryPlanner.winningPlan.stage).toBe('EXPRESS_IXSCAN');
|
||||||
|
explain = await collection._rawFind({ _id: object.id }, { hint: '_id_', explain: true });
|
||||||
|
expect(explain.queryPlanner.winningPlan.stage).toBe('FETCH');
|
||||||
|
expect(explain.queryPlanner.winningPlan.inputStage.indexName).toBe('_id_');
|
||||||
|
});
|
||||||
|
|
||||||
|
it_only_mongodb_version('<5.1 || >=6 <8')('query find with hint object', async () => {
|
||||||
const object = new TestObject();
|
const object = new TestObject();
|
||||||
await object.save();
|
await object.save();
|
||||||
|
|
||||||
@@ -78,6 +90,20 @@ describe_only_db('mongo')('Parse.Query hint', () => {
|
|||||||
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern).toEqual({ _id: 1 });
|
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern).toEqual({ _id: 1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it_only_mongodb_version('>=8')('query find with hint object', async () => {
|
||||||
|
const object = new TestObject();
|
||||||
|
await object.save();
|
||||||
|
|
||||||
|
const collection = await config.database.adapter._adaptiveCollection('TestObject');
|
||||||
|
let explain = await collection._rawFind({ _id: object.id }, { explain: true });
|
||||||
|
expect(explain.queryPlanner.winningPlan.stage).toBe('EXPRESS_IXSCAN');
|
||||||
|
explain = await collection._rawFind({ _id: object.id }, { hint: { _id: 1 }, explain: true });
|
||||||
|
expect(explain.queryPlanner.winningPlan.stage).toBe('FETCH');
|
||||||
|
expect(explain.queryPlanner.winningPlan.inputStage.keyPattern).toEqual({
|
||||||
|
_id: 1,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it_only_mongodb_version('<4.4')('query aggregate with hint string', async () => {
|
it_only_mongodb_version('<4.4')('query aggregate with hint string', async () => {
|
||||||
const object = new TestObject({ foo: 'bar' });
|
const object = new TestObject({ foo: 'bar' });
|
||||||
await object.save();
|
await object.save();
|
||||||
@@ -267,7 +293,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
|
|||||||
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
|
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it_only_mongodb_version('<5.1>=6')('query find with hint (rest)', async () => {
|
it_only_mongodb_version('<5.1 || >=6')('query find with hint (rest)', async () => {
|
||||||
const object = new TestObject();
|
const object = new TestObject();
|
||||||
await object.save();
|
await object.save();
|
||||||
let options = Object.assign({}, masterKeyOptions, {
|
let options = Object.assign({}, masterKeyOptions, {
|
||||||
|
|||||||
@@ -493,6 +493,9 @@ global.it_only_db = db => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.it_only_mongodb_version = version => {
|
global.it_only_mongodb_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
const envVersion = process.env.MONGODB_VERSION;
|
const envVersion = process.env.MONGODB_VERSION;
|
||||||
if (!envVersion || semver.satisfies(envVersion, version)) {
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
return it;
|
return it;
|
||||||
@@ -502,6 +505,9 @@ global.it_only_mongodb_version = version => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.it_only_postgres_version = version => {
|
global.it_only_postgres_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
const envVersion = process.env.POSTGRES_VERSION;
|
const envVersion = process.env.POSTGRES_VERSION;
|
||||||
if (!envVersion || semver.satisfies(envVersion, version)) {
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
return it;
|
return it;
|
||||||
@@ -511,6 +517,9 @@ global.it_only_postgres_version = version => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.it_only_node_version = version => {
|
global.it_only_node_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
const envVersion = process.version;
|
const envVersion = process.version;
|
||||||
if (!envVersion || semver.satisfies(envVersion, version)) {
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
return it;
|
return it;
|
||||||
@@ -520,6 +529,9 @@ global.it_only_node_version = version => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.fit_only_mongodb_version = version => {
|
global.fit_only_mongodb_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
const envVersion = process.env.MONGODB_VERSION;
|
const envVersion = process.env.MONGODB_VERSION;
|
||||||
if (!envVersion || semver.satisfies(envVersion, version)) {
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
return fit;
|
return fit;
|
||||||
@@ -528,7 +540,22 @@ global.fit_only_mongodb_version = version => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
global.fit_only_postgres_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
|
const envVersion = process.env.POSTGRES_VERSION;
|
||||||
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
|
return fit;
|
||||||
|
} else {
|
||||||
|
return xit;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
global.fit_only_node_version = version => {
|
global.fit_only_node_version = version => {
|
||||||
|
if (!semver.validRange(version)) {
|
||||||
|
throw new Error('Invalid version range');
|
||||||
|
}
|
||||||
const envVersion = process.version;
|
const envVersion = process.version;
|
||||||
if (!envVersion || semver.satisfies(envVersion, version)) {
|
if (!envVersion || semver.satisfies(envVersion, version)) {
|
||||||
return fit;
|
return fit;
|
||||||
@@ -537,51 +564,6 @@ global.fit_only_node_version = version => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
global.it_exclude_mongodb_version = version => {
|
|
||||||
const envVersion = process.env.MONGODB_VERSION;
|
|
||||||
if (!envVersion || !semver.satisfies(envVersion, version)) {
|
|
||||||
return it;
|
|
||||||
} else {
|
|
||||||
return xit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.it_exclude_postgres_version = version => {
|
|
||||||
const envVersion = process.env.POSTGRES_VERSION;
|
|
||||||
if (!envVersion || !semver.satisfies(envVersion, version)) {
|
|
||||||
return it;
|
|
||||||
} else {
|
|
||||||
return xit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.it_exclude_node_version = version => {
|
|
||||||
const envVersion = process.env.NODE_VERSION;
|
|
||||||
if (!envVersion || !semver.satisfies(envVersion, version)) {
|
|
||||||
return it;
|
|
||||||
} else {
|
|
||||||
return xit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.fit_exclude_mongodb_version = version => {
|
|
||||||
const envVersion = process.env.MONGODB_VERSION;
|
|
||||||
if (!envVersion || !semver.satisfies(envVersion, version)) {
|
|
||||||
return fit;
|
|
||||||
} else {
|
|
||||||
return xit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.fit_exclude_node_version = version => {
|
|
||||||
const envVersion = process.env.NODE_VERSION;
|
|
||||||
if (!envVersion || !semver.satisfies(envVersion, version)) {
|
|
||||||
return fit;
|
|
||||||
} else {
|
|
||||||
return xit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.fit_exclude_dbs = excluded => {
|
global.fit_exclude_dbs = excluded => {
|
||||||
if (excluded.indexOf(process.env.PARSE_SERVER_TEST_DB) >= 0) {
|
if (excluded.indexOf(process.env.PARSE_SERVER_TEST_DB) >= 0) {
|
||||||
return xit;
|
return xit;
|
||||||
|
|||||||
Reference in New Issue
Block a user