function test_a_b_with_dead_node() { $this->cb->set("a", '{"a":1}'); $this->cb->set("b", '{"a":2}'); $view = new Couchbase_View(); $view->setMapFunction("function(doc) { emit(doc.a, 1); }"); $this->cb->addView("default", "cluster", $view); sleep(10); $this->kill_node(1); $view = $this->cb->getView("default", "cluster"); $result = $view->getResult(); $this->assertInstanceOf("Couchbase_ViewResult", $result); $this->assertEquals(2, count($result->rows)); $this->assertEquals("1", $result->rows[0]->key); $this->assertEquals("2", $result->rows[1]->key); }
function prepare_ddoc($with_reduce = false) { $map_fun = <<<EOC_JS function(doc) { if(doc.name) { emit(doc.name, 1); } } EOC_JS; $view = new Couchbase_View("default", "name"); $view->setMapFunction($map_fun); if ($with_reduce) { $reduce_fun = <<<EOC_JS function(k,v,r) { return sum(v); } EOC_JS; $view->setReduceFunction($reduce_fun); } $this->cb->addView($view); }