Permalink
Browse files

Lots and lots of fixes

Network failure tests

Memcached interop compatibility tests

Conversion/Deconversion settings tested
Timeout settings tested
Network failure behavior tested
Some more build utilities
  • Loading branch information...
1 parent 6892af5 commit 94b63d3ed06860d90440d0daa10264ac89f1692d @mnunberg mnunberg committed Feb 9, 2012
View
@@ -1,3 +1,6 @@
[submodule "Config"]
path = Config
- url = file://Config
+ url = git://github.com/mnunberg/perl/Couchbase-Config.git
+[submodule "VBucket"]
+ path = VBucket
+ url = git://github.com/mnunberg/perl-Couchbase-VBucket.git
View
@@ -122,11 +122,11 @@ PLCB_connect(SV *self)
return 1;
} else {
if( (err = libcouchbase_connect(instance)) == LIBCOUCHBASE_SUCCESS) {
- object->connected = 1;
libcouchbase_wait(instance);
if(av_len(object->errors) > -1) {
return 0;
}
+ object->connected = 1;
return 1;
} else {
plcb_errstack_push(object, err, NULL);
@@ -239,16 +239,6 @@ static SV *PLCB_get_common(SV *self, SV *key, int exp_offset)
_sync_return_single(object, err, syncp);
}
-SV *PLCB_get_errors(SV *self)
-{
- libcouchbase_t instance;
- PLCB_t *object;
- AV *errors;
-
- mk_instance_vars(self, instance, object);
- return newRV_inc((SV*)object->errors);
-}
-
#define set_plst_get_offset(exp_idx, exp_var, diemsg) \
if(items == (exp_idx - 1)) { \
exp_var = 0; \
@@ -383,7 +373,8 @@ enum {
SETTINGS_ALIAS_SERIALIZE,
SETTINGS_ALIAS_CONVERT,
SETTINGS_ALIAS_DECONVERT,
- SETTINGS_ALIAS_COMP_THRESHOLD
+ SETTINGS_ALIAS_COMP_THRESHOLD,
+ SETTINGS_ALIAS_DEREF_RVPV
};
@@ -574,6 +565,18 @@ PLCB_remove(self, key, ...)
SV *
PLCB_get_errors(self)
SV *self
+
+ PREINIT:
+ libcouchbase_t instance;
+ PLCB_t *object;
+ AV *errors;
+
+ CODE:
+ mk_instance_vars(self, instance, object);
+ RETVAL = newRV_inc((SV*)object->errors);
+
+ OUTPUT:
+ RETVAL
SV *
@@ -609,6 +612,7 @@ PLCB__settings(self, ...)
conversion_settings = SETTINGS_ALIAS_CONVERT
deconversion_settings = SETTINGS_ALIAS_DECONVERT
compress_threshold = SETTINGS_ALIAS_COMP_THRESHOLD
+ dereference_scalar_ref_settings = SETTINGS_ALIAS_DEREF_RVPV
PREINIT:
int flag;
@@ -630,11 +634,14 @@ PLCB__settings(self, ...)
flag = PLCBf_USE_STORABLE|PLCBf_USE_COMPRESSION;
break;
case SETTINGS_ALIAS_DECONVERT:
- flag = PLCBf_NO_DECONVERT;
+ flag = PLCBf_DECONVERT;
break;
case SETTINGS_ALIAS_COMP_THRESHOLD:
flag = PLCBf_COMPRESS_THRESHOLD;
break;
+ case SETTINGS_ALIAS_DEREF_RVPV:
+ flag = PLCBf_DEREF_RVPV;
+ break;
case 0:
die("This function should not be called directly. "
"use one of its aliases");
@@ -643,7 +650,7 @@ PLCB__settings(self, ...)
break;
}
if(items == 2) {
- new_value = sv_2bool(ST(2));
+ new_value = sv_2bool(ST(1));
} else if (items == 1) {
new_value = -1;
} else {
@@ -657,7 +664,8 @@ PLCB__settings(self, ...)
RETVAL = plcb_convert_settings(object, flag, new_value);
-
+ //warn("Report flag %d = %d", flag, RETVAL);
+
OUTPUT:
RETVAL
@@ -682,7 +690,7 @@ PLCB_timeout(self, ...)
if(items == 2) {
new_param = SvNV(ST(1));
- if(!new_param) {
+ if(new_param <= 0) {
warn("Cannot disable timeouts.");
XSRETURN_UNDEF;
}
@@ -699,12 +707,18 @@ int
PLCB_connect(self)
SV *self
-
+
BOOT:
{
-
- /*because xsubpp is stupid, we can't use an inline macro for this*/
-
+ {
+ libcouchbase_uint32_t cbc_version = 0;
+ const char *cbc_version_string;
+ cbc_version_string = libcouchbase_get_version(&cbc_version);
+ /*
+ warn("Couchbase library version is (%s) %x",
+ cbc_version_string, cbc_version);
+ */
+ }
/*Client_multi.xs*/
PUSHMARK(SP);
mXPUSHs(newSVpv("Couchbase::Client",0));
2 Config
Submodule Config updated from d746dd to af3708
View
@@ -3,6 +3,7 @@ MANIFEST
MANIFEST.SKIP
Makefile.PL
README.pod
+PLCB_ConfUtil.pm
lib/Couchbase/Client.pm
lib/Couchbase/Client/Return.pm
@@ -24,6 +25,7 @@ lib/Couchbase/Test/Async.pm
lib/Couchbase/Test/Async/Loop.pm
lib/Couchbase/Test/Settings.pm
lib/Couchbase/Test/Interop.pm
+lib/Couchbase/Test/Netfail.pm
Client.xs
Client_multi.xs
View
@@ -5,19 +5,7 @@ use ExtUtils::MakeMaker;
use Dir::Self;
use lib __DIR__;
-
-my $plcb_config = do 'PLCB_Config.pm';
-
-my $include_path = $plcb_config->{COUCHBASE_INCLUDE_PATH} || "";
-my $library_path = $plcb_config->{COUCHBASE_LIBRARY_PATH} || "";
-
-if($include_path) {
- $include_path = "-I$include_path";
-}
-
-if($library_path) {
- $library_path = "-L$library_path";
-}
+use PLCB_ConfUtil;
# .c files
my @source_modules = qw(
@@ -77,8 +65,8 @@ WriteMakefile(
NEEDS_LINKING => 1,
OPTIMIZE => '-O0 -ggdb3 -Wdeclaration-after-statement -Werror -std=gnu89',
#CCFLAGS => '-Wdeclaration-after-statement',
- LIBS => ["$library_path -lcouchbase -lcouchbase_libevent -lvbucket"],
- INC => $include_path,
+ LIBS => [PLCB_ConfUtil::get_gcc_linker_flags],
+ INC => PLCB_ConfUtil::get_include_dir,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Couchbase-Client-*' },
);
View
@@ -0,0 +1,44 @@
+package PLCB_ConfUtil;
+use strict;
+use warnings;
+use Dir::Self;
+use lib __DIR__;
+
+my $config = do 'PLCB_Config.pm';
+if(!$config) {
+ warn("Couldn't find PLCB_Config.pm. Assuming defaults");
+ $config = {};
+}
+
+sub set_gcc_env {
+ my $existing_env = $ENV{C_INCLUDE_PATH};
+ $existing_env ||= "";
+ my $new_env = $config->{COUCHBASE_INCLUDE_PATH};
+ if(!$new_env) {
+ return;
+ } else {
+ $ENV{C_INCLUDE_PATH} = "$new_env:$existing_env";
+ }
+}
+
+sub get_gcc_linker_flags {
+ my $libpath = $config->{COUCHBASE_LIBRARY_PATH};
+ if($libpath) {
+ $libpath = "-L$libpath ";
+ } else {
+ $libpath = "";
+ }
+ $libpath .= '-lcouchbase -lcouchbase_libevent -lvbucket';
+ return $libpath;
+}
+
+sub get_include_dir {
+ my $dir = $config->{COUCHBASE_INCLUDE_PATH};
+ if($dir) {
+ return "-I$dir";
+ } else {
+ return "";
+ }
+}
+
+1;
View
@@ -1,6 +1,7 @@
package PLCB_Config;
use strict;
use warnings;
+
#this perl 'hash' contains configuration information necessary
#to bootstrap and/or configure the perl couchbase client and run
#necessary tests.
@@ -10,9 +11,10 @@ my $params = {
COUCHBASE_LIBRARY_PATH => "/sources/libcouchbase/.libs",
#URL from which to download the mock JAR file for tests
- COUCHBASE_MOCK_JARURL =>
- "http://files.couchbase.com/maven2/org/couchbase/mock/".
- "CouchbaseMock/0.5-SNAPSHOT/CouchbaseMock-0.5-20120202.071818-12.jar",
+ #COUCHBASE_MOCK_JARURL =>
+ # "http://files.couchbase.com/maven2/org/couchbase/mock/".
+ # "CouchbaseMock/0.5-SNAPSHOT/CouchbaseMock-0.5-20120202.071818-12.jar",
+ COUCHBASE_MOCK_JARURL => 'http://files.avsej.net/CouchbaseMock.jar'
};
Submodule VBucket added at 687dca
View
@@ -108,23 +108,38 @@ compression_convert(SV *meth, SV *input, int direction)
return converted;
}
+#define plcb_can_convert(object, flags) \
+ ((object->my_flags & (PLCBf_DECONVERT|flags)) == \
+ (PLCBf_DECONVERT|flags))
+
void plcb_convert_storage(
PLCB_t *object, SV **data_sv, STRLEN *data_len,
uint32_t *flags)
{
SV *sv;
*flags = 0;
- if(object->my_flags & PLCBf_DO_CONVERSION == 0 && SvROK(*data_sv) == 0) {
+ /* dereference SCALAR reference. bypass all conversion checks because
+ * this is an internal setting
+ */
+ if( (object->my_flags & PLCBf_DEREF_RVPV) &&
+ SvROK(*data_sv) && SvTYPE(SvRV(*data_sv)) == SVt_PV) {
+ *data_sv = SvRV(*data_sv);
+ *data_len = SvCUR(*data_sv);
+ }
+
+ if( (object->my_flags & PLCBf_DO_CONVERSION == 0 ||
+ object->my_flags & PLCBf_DECONVERT == 0)
+ && SvROK(*data_sv) == 0) {
return;
}
sv = *data_sv;
+ /*only serialize references*/
if(SvROK(sv)) {
- if(!(object->my_flags & PLCBf_USE_STORABLE)) {
- die("Serialization not enabled "
- "but we were passed a reference");
+ if(!plcb_can_convert(object, PLCBf_USE_STORABLE)) {
+ croak("serialization requested but output conversion disabled");
}
sv = serialize_convert(object->cv_serialize, sv,
@@ -133,7 +148,7 @@ void plcb_convert_storage(
*data_len = SvCUR(sv); /*set this so compression method sees new length*/
}
- if( (object->my_flags & PLCBf_USE_COMPRESSION)
+ if( plcb_can_convert(object, PLCBf_USE_COMPRESSION)
&& object->compress_threshold
&& *data_len >= object->compress_threshold ) {
@@ -166,7 +181,7 @@ SV* plcb_convert_retrieval(
input_sv = newSVpvn(data, data_len);
if(plcb_storeflags_has_conversion(object, flags) == 0
- || (object->my_flags & PLCBf_NO_DECONVERT) ) {
+ || (object->my_flags & PLCBf_DECONVERT) == 0 ) {
return input_sv;
}
@@ -194,15 +209,16 @@ SV* plcb_convert_retrieval(
int plcb_convert_settings(PLCB_t *object, int flag, int new_value)
{
int ret;
-
-
if(flag == PLCBf_COMPRESS_THRESHOLD) {
/*this isn't really a flag value, but a proper integer*/
ret = object->compress_threshold;
object->compress_threshold = new_value >= 0
? new_value
: object->compress_threshold;
+ if(new_value >= 0) {
+ object->my_flags |= PLCBf_USE_COMPRESSION;
+ }
return ret;
}
@@ -216,9 +232,5 @@ int plcb_convert_settings(PLCB_t *object, int flag, int new_value)
}
}
- if(flag == PLCBf_NO_DECONVERT && new_value > 0) {
- object->my_flags &= (~ (PLCBf_USE_COMPRESSION|PLCBf_USE_STORABLE));
- }
-
return ret;
}
View
3 ctor.c
@@ -82,7 +82,8 @@ void plcb_ctor_init_common(PLCB_t *object, libcouchbase_t instance,
}
/*gather instance-related options from the constructor*/
- if( (tmpsv = av_fetch(options, PLCB_CTORIDX_TIMEOUT, 0)) ) {
+ if( (tmpsv = av_fetch(options, PLCB_CTORIDX_TIMEOUT, 0)) &&
+ (SvIOK(*tmpsv) || SvNOK(*tmpsv))) {
timeout_value = SvNV(*tmpsv);
if(!timeout_value) {
warn("Cannot use 0 for timeout");
View
@@ -1,4 +1,6 @@
use ExtUtils::H2PM;
+use PLCB_ConfUtil;
+PLCB_ConfUtil::set_gcc_env();
module "Couchbase::Client::Errors";
use_export;
@@ -28,6 +30,8 @@
UNKNOWN_COMMAND
UNKNOWN_HOST
PROTOCOL_ERROR
+ ETIMEDOUT
+ CONNECT_ERROR
BUCKET_ENOENT
);
foreach my $cbase (@constant_basenames) {
Oops, something went wrong.

0 comments on commit 94b63d3

Please sign in to comment.