Skip to content

Commit c7bd53c

Browse files
committed
Merge pull request #30 from datastax/feature_regression_tests
Feature regression tests
2 parents 1027c6f + 03812c9 commit c7bd53c

18 files changed

+580
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/venv/
77
/tmp/*
88
/docs/
9+
/cassandra.log

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ install:
3131
before_script:
3232
# Use the most-up-to-date run-tests. old ones like 5.3 don't report failure exit codes
3333
- wget -O ext/run-tests.php https://raw.githubusercontent.com/php/php-src/master/run-tests.php
34+
# Use the BEHAT_EXTRA_OPTIONS to supply options to Behat runs
35+
- BEHAT_EXTRA_OPTIONS=
36+
# Use the BEHAT_SKIP_TAGS to skip tests on TravisCI
37+
- BEHAT_SKIP_TAGS=~@skip-travisci
38+
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]]; then BEHAT_SKIP_TAGS="${BEHAT_SKIP_TAGS}&&~@php-version-5.4"; fi
39+
- export BEHAT_EXTRA_OPTIONS BEHAT_SKIP_TAGS
3440

3541
script:
3642
- cd ext && make test && cd "$TRAVIS_BUILD_DIR" # .phpt tests
3743
- ./bin/phpunit
38-
- ./bin/behat
44+
- ./bin/behat --tags="${BEHAT_SKIP_TAGS}" ${BEHAT_EXTRA_OPTIONS}

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Vagrant.configure("2") do |config|
4242
echo "Compiling and installing the extension..."
4343
pushd /usr/local/src/php-driver/ext
4444
phpize
45-
LDFLAGS="-L$builddir/lib" LIBS="-lssl -lz -luv -lgmp -lstdc++" ./configure --with-cassandra=/tmp/php-driver-installation/build --with-gmp=/tmp/php-driver-installation/build --with-libdir=lib
45+
LDFLAGS="-L$builddir/lib" LIBS="-lssl -lz -luv -lm -lgmp -lstdc++" ./configure --with-cassandra=/tmp/php-driver-installation/build --with-gmp=/tmp/php-driver-installation/build --with-libdir=lib
4646
make
4747
sudo make install
4848
sudo sh -c 'echo "extension=cassandra.so" > /etc/php5/cli/conf.d/100-cassandra.ini'

behat.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
default:
2+
formatters:
3+
pretty: true
4+
suites:
5+
default:
6+
contexts:
7+
- FeatureContext:
8+
cluster_name: php-driver-2.1-cluster
9+
cassandra_version: 2.1.5
10+
11+
cassandra-version-2.0:
12+
formatters:
13+
pretty: true
14+
suites:
15+
default:
16+
filters: "~@cassandra-version-2.1"
17+
contexts:
18+
- FeatureContext:
19+
cluster_name: php-driver-2.0-cluster
20+
cassandra_version: 2.0.13
21+
22+
cassandra-version-1.2:
23+
formatters:
24+
pretty: true
25+
suites:
26+
default:
27+
filters:
28+
tags: "~@cassandra-version-2.0&&~@cassandra-version-2.1"
29+
contexts:
30+
- FeatureContext:
31+
cluster_name: php-driver-1.2-cluster
32+
cassandra_version: 1.2.19

ext/php_cassandra.c

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include <fcntl.h>
1010
#include <uv.h>
1111

12-
#define PHP_CASSANDRA_DEFAULT_LOG "php-driver.log"
12+
#define PHP_CASSANDRA_DEFAULT_LOG "cassandra.log"
13+
#define PHP_CASSANDRA_DEFAULT_LOG_LEVEL "ERROR"
1314

1415
static uv_once_t log_once = UV_ONCE_INIT;
1516
static char* log_location = NULL;
@@ -98,7 +99,7 @@ php_cassandra_log(const CassLogMessage* message, void* data)
9899
int fd = -1;
99100
#ifndef _WIN32
100101
if (!strcmp(log, "syslog")) {
101-
php_syslog(LOG_NOTICE, "php-driver | [%s] %s (%s:%d)",
102+
php_syslog(LOG_NOTICE, "cassandra | [%s] %s (%s:%d)",
102103
cass_log_level_string(message->severity), message->message,
103104
message->file, message->line);
104105
return;
@@ -143,7 +144,7 @@ php_cassandra_log(const CassLogMessage* message, void* data)
143144
* logging function are thread-safe.
144145
*/
145146

146-
fprintf(stderr, "php-driver | [%s] %s (%s:%d)%s",
147+
fprintf(stderr, "cassandra | [%s] %s (%s:%d)%s",
147148
cass_log_level_string(message->severity), message->message,
148149
message->file, message->line,
149150
PHP_EOL);
@@ -192,9 +193,24 @@ static PHP_INI_MH(OnUpdateLogLevel)
192193
/* If TSRM is enabled then the last thread to update this wins */
193194

194195
if (new_value) {
195-
long log_level = zend_atol(new_value, new_value_length);
196-
if (log_level > CASS_LOG_DISABLED && log_level < CASS_LOG_LAST_ENTRY)
197-
cass_log_set_level((CassLogLevel) log_level);
196+
if (strcmp(new_value, "CRITICAL") == 0) {
197+
cass_log_set_level(CASS_LOG_DISABLED);
198+
} else if (strcmp(new_value, "ERROR") == 0) {
199+
cass_log_set_level(CASS_LOG_ERROR);
200+
} else if (strcmp(new_value, "WARN") == 0) {
201+
cass_log_set_level(CASS_LOG_WARN);
202+
} else if (strcmp(new_value, "INFO") == 0) {
203+
cass_log_set_level(CASS_LOG_INFO);
204+
} else if (strcmp(new_value, "DEBUG") == 0) {
205+
cass_log_set_level(CASS_LOG_DEBUG);
206+
} else if (strcmp(new_value, "TRACE") == 0) {
207+
cass_log_set_level(CASS_LOG_TRACE);
208+
} else {
209+
php_error_docref(NULL TSRMLS_CC, E_NOTICE,
210+
"cassandra | Unknown log level '%s', using 'ERROR'",
211+
new_value);
212+
cass_log_set_level(CASS_LOG_ERROR);
213+
}
198214
}
199215

200216
return SUCCESS;
@@ -212,8 +228,11 @@ static PHP_INI_MH(OnUpdateLog)
212228
if (new_value) {
213229
if (strcmp(new_value, "syslog") != 0) {
214230
char realpath[MAXPATHLEN + 1];
215-
if (VCWD_REALPATH(new_value, realpath))
231+
if (VCWD_REALPATH(new_value, realpath)) {
216232
log_location = strdup(realpath);
233+
} else {
234+
log_location = strdup(new_value);
235+
}
217236
} else {
218237
log_location = strdup(new_value);
219238
}
@@ -224,8 +243,8 @@ static PHP_INI_MH(OnUpdateLog)
224243
}
225244

226245
PHP_INI_BEGIN()
227-
PHP_INI_ENTRY("cassandra.log", PHP_CASSANDRA_DEFAULT_LOG, PHP_INI_ALL, OnUpdateLog)
228-
PHP_INI_ENTRY("cassandra.log_level", NULL, PHP_INI_ALL, OnUpdateLogLevel)
246+
PHP_INI_ENTRY("cassandra.log", PHP_CASSANDRA_DEFAULT_LOG, PHP_INI_ALL, OnUpdateLog)
247+
PHP_INI_ENTRY("cassandra.log_level", PHP_CASSANDRA_DEFAULT_LOG_LEVEL, PHP_INI_ALL, OnUpdateLogLevel)
229248
PHP_INI_END()
230249

231250
static PHP_GINIT_FUNCTION(cassandra)
@@ -353,6 +372,8 @@ PHP_MINFO_FUNCTION(cassandra)
353372
php_info_print_table_row(2, "Persistent Sessions", buf);
354373

355374
php_info_print_table_end();
375+
376+
DISPLAY_INI_ENTRIES();
356377
}
357378

358379
zend_class_entry*

ext/template.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ BEGIN
4747
VALUE "LegalCopyright", "Copyright � 2015 DataStax, Inc."
4848
VALUE "OriginalFilename", FILE_NAME
4949
VALUE "ProductName", "Cassandra PHP driver " BUILD_INFORMATION
50-
VALUE "ProductVersion", PHP_CASSANDRA_EXTVER
50+
VALUE "ProductVersion", PHP_CASSANDRA_VERSION
5151
VALUE "URL", "http://www.datastax.com"
5252
END
5353
END

features/batch_statements.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@cassandra-version-2.0
12
Feature: Batch statements
23

34
PHP Driver supports batch statements. There are three types of batch statements:
@@ -18,7 +19,7 @@ Feature: Batch statements
1819
"""cql
1920
CREATE KEYSPACE simplex WITH replication = {
2021
'class': 'SimpleStrategy',
21-
'replication_factor': 3
22+
'replication_factor': 1
2223
};
2324
USE simplex;
2425
CREATE TABLE playlists (

0 commit comments

Comments
 (0)