|
1 | 1 | --TEST--
|
2 |
| -Causal consistency: unacknowledged write does not update operationTime |
| 2 | +Causal consistency: custom read concern merges afterClusterTime and level |
| 3 | +--DESCRIPTION-- |
| 4 | +Causal consistency spec prose test #9 |
| 5 | +https://github.com/mongodb/specifications/blob/master/source/causal-consistency/causal-consistency.rst#test-plan |
3 | 6 | --SKIPIF--
|
4 | 7 | <?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
|
5 | 8 | <?php skip_if_not_libmongoc_crypto(); ?>
|
6 | 9 | <?php skip_if_not_replica_set_or_sharded_cluster_with_replica_set(); ?>
|
7 | 10 | <?php skip_if_server_version('<', '3.6'); ?>
|
8 |
| -<?php skip_if_not_clean(); ?> |
9 | 11 | --FILE--
|
10 | 12 | <?php
|
11 | 13 | require_once __DIR__ . "/../utils/basic.inc";
|
| 14 | +require_once __DIR__ . "/../utils/observer.php"; |
12 | 15 |
|
13 |
| -$manager = create_test_manager(); |
14 |
| -$session = $manager->startSession(); |
| 16 | +(new CommandObserver)->observe( |
| 17 | + function() { |
| 18 | + $manager = create_test_manager(); |
| 19 | + $session = $manager->startSession(); |
15 | 20 |
|
16 |
| -echo "Initial operation time:\n"; |
17 |
| -var_dump($session->getOperationTime()); |
| 21 | + $readConcern = new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::MAJORITY); |
| 22 | + $query = new MongoDB\Driver\Query([], ['readConcern' => $readConcern]); |
| 23 | + $manager->executeQuery(NS, $query, ['session' => $session]); |
| 24 | + $manager->executeQuery(NS, $query, ['session' => $session]); |
| 25 | + }, |
| 26 | + function(stdClass $command) |
| 27 | + { |
| 28 | + $hasAfterClusterTime = isset($command->readConcern->afterClusterTime); |
| 29 | + printf("Read concern includes afterClusterTime: %s\n", ($hasAfterClusterTime ? 'yes' : 'no')); |
18 | 30 |
|
19 |
| -$bulk = new MongoDB\Driver\BulkWrite; |
20 |
| -$bulk->insert(['x' => 1]); |
21 |
| -$writeConcern = new MongoDB\Driver\WriteConcern(0); |
22 |
| - |
23 |
| -/* Ignore the InvalidArgumentException for trying to combine an unacknowledged |
24 |
| - * write concern with an explicit session. */ |
25 |
| -try { |
26 |
| - $manager->executeBulkWrite(NS, $bulk, ['session' => $session, 'writeConcern' => $writeConcern]); |
27 |
| -} catch (MongoDB\Driver\Exception\InvalidArgumentException $e) {} |
28 |
| - |
29 |
| -echo "\nOperation time after unacknowledged write:\n"; |
30 |
| -var_dump($session->getOperationTime()); |
| 31 | + $hasLevel = isset($command->readConcern->level); |
| 32 | + printf("Read concern includes level: %s\n", ($hasLevel ? 'yes' : 'no')); |
| 33 | + } |
| 34 | +); |
31 | 35 |
|
32 | 36 | ?>
|
33 | 37 | ===DONE===
|
34 | 38 | <?php exit(0); ?>
|
35 | 39 | --EXPECT--
|
36 |
| -Initial operation time: |
37 |
| -NULL |
38 |
| - |
39 |
| -Operation time after unacknowledged write: |
40 |
| -NULL |
| 40 | +Read concern includes afterClusterTime: no |
| 41 | +Read concern includes level: yes |
| 42 | +Read concern includes afterClusterTime: yes |
| 43 | +Read concern includes level: yes |
41 | 44 | ===DONE===
|
0 commit comments