MCPcopy Create free account
hub / github.com/couchbase/cbft / testCreateIndex1Node

Function testCreateIndex1Node

rest_test.go:2178–2326  ·  view source on GitHub ↗
(t *testing.T, planParams []string,
	expNumPIndexes, expNumFeeds int)

Source from the content-addressed store, hash-verified

2176}
2177
2178func testCreateIndex1Node(t *testing.T, planParams []string,
2179 expNumPIndexes, expNumFeeds int) (
2180 cbgt.Cfg, *cbgt.Manager, *mux.Router) {
2181 cfg := cbgt.NewCfgMem()
2182
2183 rest.RequestProxyStubFunc = func() bool {
2184 return false
2185 }
2186 emptyDir0, _ := ioutil.TempDir("./tmp", "test")
2187 defer func() {
2188 os.RemoveAll(emptyDir0)
2189 rest.RequestProxyStubFunc = nil
2190 }()
2191
2192 meh0 := &TestMEH{}
2193 options0 := map[string]string{"maxReplicasAllowed": "1",
2194 "enablePartitionNodeStickiness": "true"}
2195 mgr0 := cbgt.NewManagerEx(cbgt.VERSION, cfg, cbgt.NewUUID(),
2196 nil, "", 1, "", "localhost:1000", emptyDir0, "some-datasource",
2197 meh0, options0)
2198 mgr0.Start("wanted")
2199 mgr0.Kick("test-start-kick")
2200 mr0, _ := cbgt.NewMsgRing(os.Stderr, 1000)
2201 router0, _, err := NewRESTRouter("v0", mgr0, "static", "", mr0, nil)
2202 if err != nil || router0 == nil {
2203 t.Errorf("no mux router")
2204 }
2205
2206 nd, _, err := cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_KNOWN)
2207 if err != nil {
2208 t.Errorf("expected node defs known")
2209 }
2210 if len(nd.NodeDefs) != 1 {
2211 t.Errorf("expected 1 node defs unknown")
2212 }
2213
2214 nd, _, err = cbgt.CfgGetNodeDefs(cfg, cbgt.NODE_DEFS_WANTED)
2215 if err != nil {
2216 t.Errorf("expected node defs wanted")
2217 }
2218 if len(nd.NodeDefs) != 1 {
2219 t.Errorf("expected 1 node defs wanted")
2220 }
2221
2222 mgr0.Kick("test-start-kick-again")
2223
2224 httpGetPrev := HttpGet
2225 defer func() { HttpGet = httpGetPrev }()
2226
2227 HttpGet = func(client *http.Client, urlStr string) (
2228 resp *http.Response, err error) {
2229 u, _ := url.Parse(urlStr)
2230 req := &http.Request{
2231 Method: "GET",
2232 URL: u,
2233 Body: ioutil.NopCloser(bytes.NewBuffer([]byte{})),
2234 }
2235 record := httptest.NewRecorder()

Calls 3

NewRESTRouterFunction · 0.85
testRESTHandlersFunction · 0.85
ServeHTTPMethod · 0.45

Tested by

no test coverage detected