Skip to content

Commit ba0c0f8

Browse files
committed
Use groups to skip tests for matrix testing
1 parent 2129841 commit ba0c0f8

12 files changed

+95
-3
lines changed

.evergreen/run-tests.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ if [ "$IS_MATRIX_TESTING" == "true" ]; then
2828
;;
2929
esac
3030

31+
case "${MONGODB_VERSION}" in
32+
latest)
33+
MONGODB_VERSION_NUMBER='5.0'
34+
;;
35+
*)
36+
MONGODB_VERSION_NUMBER=$MONGODB_VERSION
37+
;;
38+
esac
39+
40+
PHPUNIT_OPTS="--dont-report-useless-tests --exclude-group matrix-testing-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION},matrix-testing-server-${MONGODB_VERSION_NUMBER}-driver-${DRIVER_MONGODB_VERSION}-topology-${TOPOLOGY}"
41+
3142
DIR=$(dirname $0)
3243
. $DIR/install-dependencies.sh
3344
fi
@@ -43,6 +54,6 @@ export SYMFONY_DEPRECATIONS_HELPER=999999
4354
# Run the tests, and store the results in a Evergreen compatible JSON results file
4455
case "$TESTS" in
4556
*)
46-
php vendor/bin/phpunit --configuration phpunit.evergreen.xml
57+
php vendor/bin/phpunit --configuration phpunit.evergreen.xml $PHPUNIT_OPTS
4758
;;
4859
esac

tests/Collection/CollectionFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ public function testWithOptionsPassesOptions()
227227
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
228228
}
229229

230+
/**
231+
* @group matrix-testing-server-4.4-driver-4.0
232+
* @group matrix-testing-server-5.0-driver-4.0
233+
*/
230234
public function testMapReduce()
231235
{
232236
$this->createFixtures(3);

tests/Collection/CrudSpecFunctionalTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* CRUD spec functional tests.
1313
*
1414
* @see https://github.com/mongodb/specifications/tree/master/source/crud/tests
15+
*
16+
* @group matrix-testing-server-5.0-driver-4.0
1517
*/
1618
class CrudSpecFunctionalTest extends FunctionalTestCase
1719
{

tests/Database/DatabaseFunctionalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ public function testGetSelectsCollectionAndInheritsOptions()
153153
$this->assertSame(WriteConcern::MAJORITY, $debug['writeConcern']->getW());
154154
}
155155

156+
/**
157+
* @group matrix-testing-server-4.2-driver-4.0-topology-sharded_cluster
158+
* @group matrix-testing-server-4.4-driver-4.0-topology-sharded_cluster
159+
* @group matrix-testing-server-5.0-driver-4.0-topology-sharded_cluster
160+
*/
156161
public function testModifyCollection()
157162
{
158163
$this->database->createCollection($this->getCollectionName());

tests/DocumentationExamplesTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ public function testExample_55_58()
919919
$this->assertInventoryCount(0);
920920
}
921921

922+
/** @group matrix-testing-server-5.0-driver-4.0-topology-sharded_cluster */
922923
public function testChangeStreamExample_1_4()
923924
{
924925
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) {

tests/FunctionalTestCase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId)
4848

4949
protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null)
5050
{
51+
if ($this->isShardedCluster()) {
52+
return $this->getServerVersion($readPreference);
53+
}
54+
5155
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {
5256
return $this->getServerVersion($readPreference);
5357
}
@@ -133,4 +137,9 @@ protected function skipIfTransactionsAreNotSupported()
133137
$this->markTestSkipped('Transactions require WiredTiger storage engine');
134138
}
135139
}
140+
141+
protected function isShardedCluster()
142+
{
143+
return $this->getPrimaryServer()->getType() == Server::TYPE_MONGOS;
144+
}
136145
}

tests/Model/IndexInfoFunctionalTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function testIs2dSphere()
4242
$this->assertEquals($expectedVersion, $index['2dsphereIndexVersion']);
4343
}
4444

45+
/** @group matrix-testing-server-5.0-driver-4.0 */
4546
public function testIsGeoHaystack()
4647
{
4748
$indexName = $this->collection->createIndex(['pos' => 'geoHaystack', 'x' => 1], ['bucketSize' => 5]);

tests/Operation/AggregateFunctionalTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,13 @@ public function testExplainOption()
162162
$results = iterator_to_array($operation->execute($this->getPrimaryServer()));
163163

164164
$this->assertCount(1, $results);
165-
$this->assertArrayHasKey('stages', $results[0]);
165+
166+
/* MongoDB 4.2 may optimize aggregate pipelines into queries, which can
167+
* result in different explain output (see: SERVER-24860) */
168+
$this->assertThat($results[0], $this->logicalOr(
169+
$this->arrayHasKey('stages'),
170+
$this->arrayHasKey('queryPlanner')
171+
));
166172
}
167173

168174
public function testExplainOptionWithWriteConcern()
@@ -183,7 +189,17 @@ function() use ($pipeline, $options) {
183189
$results = iterator_to_array($operation->execute($this->getPrimaryServer()));
184190

185191
$this->assertCount(1, $results);
186-
$this->assertObjectHasAttribute('stages', current($results));
192+
$result = current($results);
193+
194+
/* MongoDB 4.2 may optimize aggregate pipelines into queries, which can
195+
* result in different explain output (see: SERVER-24860) */
196+
if (isset($result->shards)) {
197+
foreach ($result->shards as $shard) {
198+
$this->assertObjectHasAttribute('stages', $shard);
199+
}
200+
} else {
201+
$this->assertObjectHasAttribute('stages', $result);
202+
}
187203
},
188204
function(array $event) {
189205
$this->assertObjectNotHasAttribute('writeConcern', $event['started']->getCommand());

tests/Operation/ListCollectionsFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function testListCollectionsForNewlyCreatedDatabase()
3434
}
3535
}
3636

37+
/**
38+
* @group matrix-testing-server-4.4-driver-4.0
39+
* @group matrix-testing-server-5.0-driver-4.0
40+
*/
3741
public function testIdIndexAndInfo()
3842
{
3943
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {

tests/Operation/MapReduceFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
use MongoDB\Tests\CommandObserver;
1212
use stdClass;
1313

14+
/**
15+
* @group matrix-testing-server-4.4-driver-4.0
16+
* @group matrix-testing-server-5.0-driver-4.0
17+
*/
1418
class MapReduceFunctionalTest extends FunctionalTestCase
1519
{
1620
public function testDefaultReadConcernIsOmitted()

tests/Operation/ModifyCollectionFunctionalTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
class ModifyCollectionFunctionalTest extends FunctionalTestCase
1010
{
11+
/**
12+
* @group matrix-testing-server-4.2-driver-4.0-topology-sharded_cluster
13+
* @group matrix-testing-server-4.4-driver-4.0-topology-sharded_cluster
14+
* @group matrix-testing-server-5.0-driver-4.0-topology-sharded_cluster
15+
*/
1116
public function testCollMod()
1217
{
1318
$operation = new CreateCollection($this->getDatabaseName(), $this->getCollectionName());

tests/Operation/WatchFunctionalTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
use stdClass;
2020
use ReflectionClass;
2121

22+
/**
23+
* @group matrix-testing-server-4.2-driver-4.0-topology-sharded_cluster
24+
* @group matrix-testing-server-4.4-driver-4.0-topology-sharded_cluster
25+
* @group matrix-testing-server-5.0-driver-4.0-topology-sharded_cluster
26+
*/
2227
class WatchFunctionalTest extends FunctionalTestCase
2328
{
2429
private static $wireVersionForStartAtOperationTime = 7;
@@ -590,6 +595,11 @@ public function testInitialCursorIsNotClosed()
590595
$this->assertFalse($cursor->isDead());
591596
}
592597

598+
/**
599+
* @group matrix-testing-server-4.2-driver-4.0-topology-replica_set
600+
* @group matrix-testing-server-4.4-driver-4.0-topology-replica_set
601+
* @group matrix-testing-server-5.0-driver-4.0-topology-replica_set
602+
*/
593603
public function testNextResumeTokenNotFound()
594604
{
595605
$pipeline = [['$project' => ['_id' => 0 ]]];
@@ -606,6 +616,11 @@ public function testNextResumeTokenNotFound()
606616
$changeStream->next();
607617
}
608618

619+
/**
620+
* @group matrix-testing-server-4.2-driver-4.0-topology-replica_set
621+
* @group matrix-testing-server-4.4-driver-4.0-topology-replica_set
622+
* @group matrix-testing-server-5.0-driver-4.0-topology-replica_set
623+
*/
609624
public function testRewindResumeTokenNotFound()
610625
{
611626
$pipeline = [['$project' => ['_id' => 0 ]]];
@@ -620,6 +635,11 @@ public function testRewindResumeTokenNotFound()
620635
$changeStream->rewind();
621636
}
622637

638+
/**
639+
* @group matrix-testing-server-4.2-driver-4.0-topology-replica_set
640+
* @group matrix-testing-server-4.4-driver-4.0-topology-replica_set
641+
* @group matrix-testing-server-5.0-driver-4.0-topology-replica_set
642+
*/
623643
public function testNextResumeTokenInvalidType()
624644
{
625645
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
@@ -636,6 +656,11 @@ public function testNextResumeTokenInvalidType()
636656
$changeStream->next();
637657
}
638658

659+
/**
660+
* @group matrix-testing-server-4.2-driver-4.0-topology-replica_set
661+
* @group matrix-testing-server-4.4-driver-4.0-topology-replica_set
662+
* @group matrix-testing-server-5.0-driver-4.0-topology-replica_set
663+
*/
639664
public function testRewindResumeTokenInvalidType()
640665
{
641666
$pipeline = [['$project' => ['_id' => ['$literal' => 'foo']]]];
@@ -822,6 +847,11 @@ public function testNextAdvancesKey()
822847
$this->assertSame(1, $changeStream->key());
823848
}
824849

850+
/**
851+
* @group matrix-testing-server-4.2-driver-4.0-topology-replica_set
852+
* @group matrix-testing-server-4.4-driver-4.0-topology-replica_set
853+
* @group matrix-testing-server-5.0-driver-4.0-topology-replica_set
854+
*/
825855
public function testResumeTokenNotFoundAdvancesKey()
826856
{
827857
$pipeline = [['$project' => ['_id' => 0 ]]];

0 commit comments

Comments
 (0)