@@ -148,28 +148,22 @@ public function __construct($className,
148
148
$ query = sprintf (Integration::SIMPLE_KEYSPACE_FORMAT , $ this ->keyspaceName , $ replicationStrategy );
149
149
150
150
// Create the session and keyspace for the integration test
151
- try {
152
- // Create the session and integration test keypspace
153
- $ this ->cluster = \Cassandra::cluster ()
154
- ->withContactPoints ($ this ->getContactPoints (Integration::IP_ADDRESS , ($ numberDC1Nodes + $ numberDC2Nodes )))
155
- ->build ();
156
- $ this ->session = $ this ->cluster ->connect ();
157
- $ statement = new SimpleStatement ($ query );
158
- $ this ->session ->execute ($ statement );
151
+ $ this ->cluster = \Cassandra::cluster ()
152
+ ->withContactPoints ($ this ->getContactPoints (Integration::IP_ADDRESS , ($ numberDC1Nodes + $ numberDC2Nodes )))
153
+ ->withPersistentSessions (false )
154
+ ->build ();
155
+ $ this ->session = $ this ->cluster ->connect ();
156
+ $ statement = new SimpleStatement ($ query );
157
+ $ this ->session ->execute ($ statement );
159
158
160
- // Update the session to use the new keyspace by default
161
- $ statement = new SimpleStatement ("USE " . $ this ->keyspaceName );
162
- $ this ->session ->execute ($ statement );
159
+ // Update the session to use the new keyspace by default
160
+ $ statement = new SimpleStatement ("USE " . $ this ->keyspaceName );
161
+ $ this ->session ->execute ($ statement );
163
162
164
- // Get the server version the session is connected to
165
- $ statement = new SimpleStatement (self ::SELECT_SERVER_VERSION );
166
- $ rows = $ this ->session ->execute ($ statement );
167
- $ this ->serverVersion = $ rows ->first ()["release_version " ];
168
-
169
- } catch (Exception $ e ) {
170
- printf ("Error Creating CCM Cluster: %s " . PHP_EOL . "%s " . PHP_EOL ,
171
- $ e ->getMessage (), $ e ->getTraceAsString ());
172
- }
163
+ // Get the server version the session is connected to
164
+ $ statement = new SimpleStatement (self ::SELECT_SERVER_VERSION );
165
+ $ rows = $ this ->session ->execute ($ statement );
166
+ $ this ->serverVersion = $ rows ->first ()["release_version " ];
173
167
}
174
168
175
169
public function __destruct () {
@@ -255,3 +249,25 @@ public static function disconnect() {
255
249
unset(self ::$ instance );
256
250
}
257
251
}
252
+
253
+ class IntegrationRemoveAllClusters {
254
+ private $ ccm ;
255
+ private static $ instance ;
256
+
257
+ function __construct () {
258
+ $ this ->ccm = new \CCM (\CCM ::DEFAULT_CASSANDRA_VERSION , true );
259
+ $ this ->ccm ->removeAllClusters ();
260
+ }
261
+
262
+ function __destruct () {
263
+ $ this ->ccm ->removeAllClusters ();
264
+ }
265
+
266
+ public static function cleanup () {
267
+ if (!isset ($ instance )) {
268
+ self ::$ instance = new IntegrationRemoveAllClusters ();
269
+ }
270
+ }
271
+ }
272
+
273
+ IntegrationRemoveAllClusters::cleanup ();
0 commit comments