forked from datastax/php-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consistency_level.feature
107 lines (96 loc) · 3.64 KB
/
consistency_level.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Feature: Consistency Level
PHP Driver supports consistency levels when executing statements.
Background:
Given a running Cassandra cluster with "3" nodes
And the following schema:
"""cql
CREATE KEYSPACE simplex WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': 3
};
USE simplex;
CREATE TABLE playlists (
id uuid,
title text,
album text,
artist text,
song_id uuid,
PRIMARY KEY (id, title, album, artist)
);
"""
Scenario: Consistency levels are specified via an ExecutionOptions object
Given tracing is enabled
And the following example:
"""php
<?php
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("simplex");
$insertQuery = "INSERT INTO playlists (id, song_id, artist, title, album) " .
"VALUES (62c36092-82a1-3a00-93d1-46196ee77204, " .
new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50') . ", " .
"'Joséphine Baker', " .
"'La Petite Tonkinoise', " .
"'Bye Bye Blackbird')";
// ExecutionOptions is deprecated, but still legal. Disable error reporting for it.
error_reporting(E_ALL ^ E_DEPRECATED);
$options = new Cassandra\ExecutionOptions(array('consistency' => Cassandra::CONSISTENCY_ALL));
$session->execute($insertQuery, $options);
// Restore error-reporting to normal.
error_reporting(E_ALL);
// Below uses the system_traces.events table to verify consistency ALL is met
$result = $session->execute("SELECT source from system_traces.events", $options);
$sources = array();
foreach ($result as $row) {
array_push($sources, (string) $row['source']);
}
$sources = array_unique($sources);
asort($sources);
foreach ($sources as $source) {
echo $source . "\n";
}
"""
When it is executed
Then its output should contain:
"""
127.0.0.1
127.0.0.2
127.0.0.3
"""
Scenario: Consistency levels are specified via an array of execution options
Given tracing is enabled
And the following example:
"""php
<?php
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("simplex");
$insertQuery = "INSERT INTO playlists (id, song_id, artist, title, album) " .
"VALUES (62c36092-82a1-3a00-93d1-46196ee77204, " .
new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50') . ", " .
"'Joséphine Baker', " .
"'La Petite Tonkinoise', " .
"'Bye Bye Blackbird')";
$options = array('consistency' => Cassandra::CONSISTENCY_ALL);
$session->execute($insertQuery, $options);
// Below uses the system_traces.events table to verify consistency ALL is met
$result = $session->execute("SELECT source from system_traces.events", $options);
$sources = array();
foreach ($result as $row) {
array_push($sources, (string) $row['source']);
}
$sources = array_unique($sources);
asort($sources);
foreach ($sources as $source) {
echo $source . "\n";
}
"""
When it is executed
Then its output should contain:
"""
127.0.0.1
127.0.0.2
127.0.0.3
"""