zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #17290
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
Juan Zacarias has proposed merging lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module.
Commit message:
Fixes for the view.xq test
Requested reviews:
Chris Hillery (ceejatec)
Related bugs:
Bug #1102816 in Zorba: "Couchbase view.xq test is unreliable"
https://bugs.launchpad.net/zorba/+bug/1102816
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/couchbase-test-fixes/+merge/144352
--
https://code.launchpad.net/~zorba-coders/zorba/couchbase-test-fixes/+merge/144352
Your team Zorba Coders is subscribed to branch lp:zorba/couchbase-module.
=== modified file 'src/couchbase.xq.src/couchbase.cpp'
--- src/couchbase.xq.src/couchbase.cpp 2013-01-17 22:52:59 +0000
+++ src/couchbase.xq.src/couchbase.cpp 2013-01-22 17:53:27 +0000
@@ -1189,6 +1189,27 @@
/*******************************************************************************
******************************************************************************/
+void DeleteViewFunction::delete_view_callback(lcb_http_request_t request, lcb_t instance, const void* cookie, lcb_error_t error, const lcb_http_resp_t* resp)
+{
+ if (resp->v.v0.status == 401)
+ {
+ std::ostringstream lMsg;
+ lMsg << "The item requested was not available using the supplied authorization, or authorization was not supplied.";
+ throwError("CB0012", lMsg.str().c_str());
+ } else if (resp->v.v0.status == 404)
+ {
+ std::ostringstream lMsg;
+ lMsg << "The requested content could not be found. The returned content will include further information, as a JSON object, if available.";
+ throwError("CB0012", lMsg.str().c_str());
+ }
+ else if (resp->v.v0.status > 400)
+ {
+ std::ostringstream lMsg;
+ lMsg << "HTTP communication with couchbase server throwed error " << (int)resp->v.v0.status << ".";
+ throwError("CB0012", lMsg.str().c_str());
+ }
+}
+
zorba::ItemSequence_t
DeleteViewFunction::evaluate(
const Arguments_t& aArgs,
@@ -1203,6 +1224,7 @@
lDocNames->open();
while(lDocNames->next(lDoc))
{
+ lcb_set_http_complete_callback(lInstance, DeleteViewFunction::delete_view_callback);
String lPath = "_design/" + lDoc.getStringValue();
lcb_http_request_t req;
lcb_http_cmd_t cmd;
@@ -1212,13 +1234,13 @@
cmd.v.v0.body = NULL;
cmd.v.v0.nbody = 0;
cmd.v.v0.method = LCB_HTTP_METHOD_DELETE;
- cmd.v.v0.chunked = false;
+ cmd.v.v0.chunked = 0;
cmd.v.v0.content_type = "application/json";
lcb_error_t err = lcb_make_http_request(lInstance, NULL,
LCB_HTTP_TYPE_VIEW, &cmd, &req);
if (err != LCB_SUCCESS)
- libCouchbaseError (lInstance, err);
+ libCouchbaseError (lInstance, err);
lcb_wait(lInstance);
}
@@ -1229,6 +1251,27 @@
/*******************************************************************************
******************************************************************************/
+void CreateViewFunction::create_view_callback(lcb_http_request_t request, lcb_t instance, const void* cookie, lcb_error_t error, const lcb_http_resp_t* resp)
+{
+ if (resp->v.v0.status == 401)
+ {
+ std::ostringstream lMsg;
+ lMsg << "The item requested was not available using the supplied authorization, or authorization was not supplied.";
+ throwError("CB0012", lMsg.str().c_str());
+ } else if (resp->v.v0.status == 404)
+ {
+ std::ostringstream lMsg;
+ lMsg << "The requested content could not be found. The returned content will include further information, as a JSON object, if available.";
+ throwError("CB0012", lMsg.str().c_str());
+ }
+ else if (resp->v.v0.status > 400)
+ {
+ std::ostringstream lMsg;
+ lMsg << "HTTP communication with couchbase server throwed error " << (int)resp->v.v0.status << ".";
+ throwError("CB0012", lMsg.str().c_str());
+ }
+}
+
zorba::ItemSequence_t
CreateViewFunction::evaluate(
const Arguments_t& aArgs,
@@ -1396,7 +1439,7 @@
lViewNames->close();
lBody += "}}";
}
-
+ lcb_set_http_complete_callback(lInstance, CreateViewFunction::create_view_callback);
lcb_http_request_t lReq;
lcb_http_cmd_t lCmd;
lCmd.v.v0.path = lPath.c_str();
=== modified file 'src/couchbase.xq.src/couchbase.h'
--- src/couchbase.xq.src/couchbase.h 2013-01-17 22:52:59 +0000
+++ src/couchbase.xq.src/couchbase.h 2013-01-22 17:53:27 +0000
@@ -571,6 +571,14 @@
class CreateViewFunction : public CouchbaseFunction
{
+ private:
+ static void create_view_callback(
+ lcb_http_request_t request,
+ lcb_t instance,
+ const void* cookie,
+ lcb_error_t error,
+ const lcb_http_resp_t* resp);
+
public:
CreateViewFunction(const CouchbaseModule* aModule)
: CouchbaseFunction(aModule) {}
@@ -591,6 +599,14 @@
class DeleteViewFunction : public CouchbaseFunction
{
+ private:
+ static void delete_view_callback(
+ lcb_http_request_t request,
+ lcb_t instance,
+ const void* cookie,
+ lcb_error_t error,
+ const lcb_http_resp_t* resp);
+
public:
DeleteViewFunction(const CouchbaseModule* aModule)
: CouchbaseFunction(aModule) {}
=== modified file 'test/Queries/couchbase_module/view.xq'
--- test/Queries/couchbase_module/view.xq 2013-01-17 22:52:59 +0000
+++ test/Queries/couchbase_module/view.xq 2013-01-22 17:53:27 +0000
@@ -9,13 +9,10 @@
cb:remove($instance, "view");
cb:put-text($instance, "view", '{ "view" : 1 }', { "wait" : "persist" });
-variable $cb-document := "test-view";
+variable $cb-document := "dev_test_view";
variable $cb-view := "view";
variable $view-name := cb:create-view($instance, $cb-document, $cb-view, {"key":"doc.view"});
-
variable $data := cb:view($instance, $view-name, {"stale" : "false"});
-cb:delete-view($instance, $cb-document);
for $d in jn:members($data("rows"))
where $d("key") > 0
return $d
-
Follow ups
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: noreply, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Juan Zacarias, 2013-02-05
-
Re: [Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Juan Zacarias, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
Re: [Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-02-05
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Chris Hillery, 2013-02-05
-
Re: [Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Chris Hillery, 2013-02-05
-
Re: [Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Chris Hillery, 2013-01-30
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-01-22
-
Re: [Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-01-22
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Zorba Build Bot, 2013-01-22
-
[Merge] lp:~zorba-coders/zorba/couchbase-test-fixes into lp:zorba/couchbase-module
From: Juan Zacarias, 2013-01-22