Permalink
Browse files

MB-5893 Reword error message regarding number of vBuckets

Change-Id: I34859e8bcaeebb89682aa2412057afc7f82c3294
Reviewed-on: http://review.couchbase.org/18761
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
1 parent 572e113 commit b965f4333cdc898c15052f80e4b5ee34535faf7c @avsej avsej committed with alk Jul 24, 2012
Showing with 29 additions and 3 deletions.
  1. +4 −3 src/vbucket.c
  2. +16 −0 tests/config/testapp-config-wrong-num-vbuckets
  3. +9 −0 tests/testapp.c
View
7 src/vbucket.c
@@ -31,10 +31,11 @@
#include <libvbucket/vbucket.h>
#define MAX_CONFIG_SIZE 100 * 1048576
-#define MAX_BUCKETS 65536
+#define MAX_VBUCKETS 65536
#define MAX_REPLICAS 4
#define MAX_AUTORITY_SIZE 100
-#define STRINGIFY(X) #X
+#define STRINGIFY_(X) #X
+#define STRINGIFY(X) STRINGIFY_(X)
struct server_st {
char *authority; /* host:port */
@@ -350,7 +351,7 @@ static int parse_vbucket_config(VBUCKET_CONFIG_HANDLE vb, cJSON *c)
}
vb->num_vbuckets = cJSON_GetArraySize(json);
if (vb->num_vbuckets == 0 || (vb->num_vbuckets & (vb->num_vbuckets - 1)) != 0) {
- vb->errmsg = strdup("Number of buckets must be a power of two > 0 and <= " STRINGIFY(MAX_BUCKETS));
+ vb->errmsg = strdup("Number of vBuckets must be a power of two > 0 and <= " STRINGIFY(MAX_VBUCKETS));
return -1;
}
vb->mask = vb->num_vbuckets - 1;
View
16 tests/config/testapp-config-wrong-num-vbuckets
@@ -0,0 +1,16 @@
+{
+ "hashAlgorithm": "CRC",
+ "numReplicas": 2,
+ "serverList": [
+ "server1:11211",
+ "server2:11210",
+ "server3:11211"
+ ],
+ "vBucketMap": [
+ [ 2, 1, 0 ],
+ [ 0, 1, 2 ],
+ [ 1, 2, 0 ],
+ [ 2, 1, -1 ],
+ [ 1, 2, 0 ]
+ ]
+}
View
9 tests/testapp.c
@@ -127,6 +127,14 @@ static void testWrongServer(const char *fname) {
vbucket_config_destroy(vb);
}
+static void testWrongNumVbuckets(const char *fname) {
+ VBUCKET_CONFIG_HANDLE vb = vbucket_config_create();
+ assert(vb != NULL);
+ assert(vbucket_config_parse(vb, LIBVBUCKET_SOURCE_FILE, configPath(fname)) != 0);
+ assert(strcmp(vbucket_get_error_message(vb), "Number of vBuckets must be a power of two > 0 and <= 65536") == 0);
+ vbucket_config_destroy(vb);
+}
+
static void testWrongServerFFT(const char *fname) {
VBUCKET_CONFIG_HANDLE vb = vbucket_config_parse_file(configPath(fname));
int rv = 0;
@@ -283,6 +291,7 @@ int main(void) {
testConfig("config-in-envelope-fft");
testWrongServer("config");
testWrongServerFFT("config-in-envelope-fft");
+ testWrongNumVbuckets("config-wrong-num-vbuckets");
testConfigDiff();
testConfigDiffSame();
testConfigUserPassword();

0 comments on commit b965f43

Please sign in to comment.