forked from datastax/php-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretry_polices.feature
175 lines (157 loc) · 6.64 KB
/
retry_polices.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Feature: Retry Policies
PHP Driver supports consistency levels when executing statements.
Background:
Given a running Cassandra cluster with "1" nodes
Given the following logger settings:
"""ini
cassandra.log=feature-retry-policy.log
cassandra.log_level=INFO
"""
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: Retry policy can be set when constructing the cluster
Given tracing is enabled
And the following example:
"""php
<?php
$retry_policy = new Cassandra\RetryPolicy\DowngradingConsistency();
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->withRetryPolicy(new Cassandra\RetryPolicy\Logging($retry_policy))
->build();
$session = $cluster->connect("simplex");
$statement = $session->prepare("INSERT INTO playlists (id, song_id, artist, title, album)
VALUES (62c36092-82a1-3a00-93d1-46196ee77204, ?, ?, ?, ?)");
$arguments = array(new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50'),
'Joséphine Baker',
'La Petite Tonkinoise',
'Bye Bye Blackbird'
);
$options = array(
'consistency' => Cassandra::CONSISTENCY_QUORUM,
'arguments' => $arguments
);
$session->execute($statement, $options);
$result = $session->execute("SELECT * FROM simplex.playlists");
foreach ($result as $row) {
echo $row['artist'] . ": " . $row['title'] . " / " . $row['album'] . "\n";
}
"""
When it is executed
Then its output should contain:
"""
Joséphine Baker: La Petite Tonkinoise / Bye Bye Blackbird
"""
Then a log file "feature-retry-policy.log" should exist
And the log file "feature-retry-policy.log" should contain "Retrying on unavailable error at consistency ONE"
Scenario: Retry policy can be set when executing a statement
Given tracing is enabled
And the following example:
"""php
<?php
$retry_policy = new Cassandra\RetryPolicy\DowngradingConsistency();
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("simplex");
$statement = $session->prepare("INSERT INTO playlists (id, song_id, artist, title, album)
VALUES (62c36092-82a1-3a00-93d1-46196ee77204, ?, ?, ?, ?)");
$arguments = array(new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50'),
'Joséphine Baker',
'La Petite Tonkinoise',
'Bye Bye Blackbird'
);
$options = array(
'consistency' => Cassandra::CONSISTENCY_QUORUM,
'arguments' => $arguments,
'retry_policy' => new Cassandra\RetryPolicy\Logging($retry_policy)
);
$session->execute($statement, $options);
$result = $session->execute("SELECT * FROM simplex.playlists");
foreach ($result as $row) {
echo $row['artist'] . ": " . $row['title'] . " / " . $row['album'] . "\n";
}
"""
When it is executed
Then its output should contain:
"""
Joséphine Baker: La Petite Tonkinoise / Bye Bye Blackbird
"""
Then a log file "feature-retry-policy.log" should exist
And the log file "feature-retry-policy.log" should contain "Retrying on unavailable error at consistency ONE"
# This scenario is broken because cpp-driver <= 2.2.2 fails to retry with
# a downgraded consistency when using batches. Fix:
# /~https://github.com/datastax/cpp-driver/commit/ddb21b9878dff83049dc494b5f3ecfa58bdadce5
@broken
Scenario: Retry policy can be set when executing a batch
Given tracing is enabled
And the following example:
"""php
<?php
$retry_policy = new Cassandra\RetryPolicy\DowngradingConsistency();
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("simplex");
$prepared = $session->prepare(
"INSERT INTO playlists (id, song_id, artist, title, album) " .
"VALUES (62c36092-82a1-3a00-93d1-46196ee77204, ?, ?, ?, ?)"
);
$batch = new Cassandra\BatchStatement(Cassandra::BATCH_UNLOGGED);
$options = array(
'consistency' => Cassandra::CONSISTENCY_QUORUM,
'retry_policy' => new Cassandra\RetryPolicy\Logging($retry_policy)
);
$batch->add($prepared, array(
'song_id' => new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50'),
'title' => 'La Petite Tonkinoise',
'album' => 'Bye Bye Blackbird',
'artist' => 'Joséphine Baker'
));
$batch->add(
"INSERT INTO playlists (id, song_id, artist, title, album) " .
"VALUES (62c36092-82a1-3a00-93d1-46196ee77204, ?, ?, ?, ?)",
array(
new Cassandra\Uuid('f6071e72-48ec-4fcb-bf3e-379c8a696488'),
'Willi Ostermann', 'Die Mösch', 'In Gold',
)
);
$batch->add($prepared, array(
new Cassandra\Uuid('fbdf82ed-0063-4796-9c7c-a3d4f47b4b25'),
'Mick Jager', 'Memo From Turner', 'Performance'
));
$session->execute($batch, $options);
$result = $session->execute("SELECT * FROM simplex.playlists");
foreach ($result as $row) {
echo $row['artist'] . ": " . $row['title'] . " / " . $row['album'] . "\n";
}
"""
When it is executed
Then its output should contain:
"""
Joséphine Baker: La Petite Tonkinoise / Bye Bye Blackbird
"""
And its output should contain:
"""
Willi Ostermann: Die Mösch / In Gold
"""
And its output should contain:
"""
Mick Jager: Memo From Turner / Performance
"""
Then a log file "feature-retry-policy.log" should exist
And the log file "feature-retry-policy.log" should contain "Retrying on unavailable error at consistency ONE"