diff --git a/src/test/aerospike_test.c b/src/test/aerospike_test.c index 700b50698..4073612b5 100644 --- a/src/test/aerospike_test.c +++ b/src/test/aerospike_test.c @@ -25,20 +25,21 @@ #include #include #include +#include #include "test.h" #include "aerospike_test.h" -/****************************************************************************** - * MACROS - *****************************************************************************/ +//--------------------------------- +// Macros +//--------------------------------- #define TIMEOUT 1000 #define SCRIPT_LEN_MAX 1048576 -/****************************************************************************** - * VARIABLES - *****************************************************************************/ +//--------------------------------- +// Global Variables +//--------------------------------- aerospike * as = NULL; int g_argc = 0; @@ -51,10 +52,11 @@ as_config_tls g_tls = {0}; as_auth_mode g_auth_mode = AS_AUTH_INTERNAL; bool g_enterprise_server = false; bool g_has_ttl = false; +bool g_has_sc = false; -/****************************************************************************** - * STATIC FUNCTIONS - *****************************************************************************/ +//--------------------------------- +// Static Functions +//--------------------------------- static bool as_client_log_callback(as_log_level level, const char * func, const char * file, uint32_t line, const char * fmt, ...) @@ -382,6 +384,20 @@ static bool before(atf_plan* plan) } cf_free(result); + // Determine if namespace is configured as strong consistency. + as_cluster* cluster = as->cluster; + const char* ns = "test"; + + if (cluster->shm_info) { + as_cluster_shm* cluster_shm = cluster->shm_info->cluster_shm; + as_partition_table_shm* table = as_shm_find_partition_table(cluster_shm, ns); + g_has_sc = table ? table->sc_mode : false; + } + else { + as_partition_table* table = as_partition_tables_get(&cluster->partition_tables, ns); + g_has_sc = table ? table->sc_mode : false; + } + /* // Test metrics as_metrics_policy policy; @@ -423,9 +439,9 @@ static bool after(atf_plan* plan) } } -/****************************************************************************** - * TEST PLAN - *****************************************************************************/ +//--------------------------------- +// Test Plan +//--------------------------------- PLAN(aerospike_test) { @@ -473,4 +489,3 @@ PLAN(aerospike_test) plan_add(transaction_async); #endif } - diff --git a/src/test/transaction.c b/src/test/transaction.c index 2e4b4a5fd..364a8081c 100644 --- a/src/test/transaction.c +++ b/src/test/transaction.c @@ -31,6 +31,7 @@ //--------------------------------- extern aerospike* as; +extern bool g_has_sc; //--------------------------------- // Macros @@ -895,6 +896,11 @@ TEST(txn_batch_abort, "transaction batch abort") SUITE(transaction, "Transaction tests") { + // Multi-record transactions require strong consistency namespaces. + if (!g_has_sc) { + return; + } + suite_before(before); suite_after(after); diff --git a/src/test/transaction_async.c b/src/test/transaction_async.c index 4bc6af156..b058af04a 100644 --- a/src/test/transaction_async.c +++ b/src/test/transaction_async.c @@ -33,6 +33,7 @@ //--------------------------------- extern aerospike* as; +extern bool g_has_sc; static as_monitor monitor; //--------------------------------- @@ -1129,6 +1130,11 @@ TEST(txn_async_batch_abort, "transaction async batch abort") SUITE(transaction_async, "Async transaction tests") { + // Multi-record transactions require strong consistency namespaces. + if (!g_has_sc) { + return; + } + suite_before(before); suite_after(after);