libcouchbase 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#include "config.h"
|
|
2
|
+
#include "iotests.h"
|
|
3
|
+
#include <libcouchbase/couchbase.h>
|
|
4
|
+
#include <libcouchbase/n1ql.h>
|
|
5
|
+
#include "internal.h"
|
|
6
|
+
|
|
7
|
+
using std::vector;
|
|
8
|
+
using std::string;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
struct N1QLResult {
|
|
12
|
+
vector<string> rows;
|
|
13
|
+
string meta;
|
|
14
|
+
int htcode;
|
|
15
|
+
lcb_error_t rc;
|
|
16
|
+
bool called;
|
|
17
|
+
|
|
18
|
+
N1QLResult() {
|
|
19
|
+
reset();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void reset() {
|
|
23
|
+
called = false;
|
|
24
|
+
rc = LCB_SUCCESS;
|
|
25
|
+
meta.clear();
|
|
26
|
+
rows.clear();
|
|
27
|
+
htcode = 0;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
#define SKIP_QUERY_TEST() \
|
|
32
|
+
fprintf(stderr, "Requires recent mock with query support"); \
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
extern "C" {
|
|
36
|
+
static void rowcb(lcb_t, int, const lcb_RESPN1QL *resp)
|
|
37
|
+
{
|
|
38
|
+
N1QLResult *res = reinterpret_cast<N1QLResult*>(resp->cookie);
|
|
39
|
+
if (resp->rflags & LCB_RESP_F_FINAL) {
|
|
40
|
+
res->rc = resp->rc;
|
|
41
|
+
if (resp->row) {
|
|
42
|
+
res->meta.assign(static_cast<const char*>(resp->row), resp->nrow);
|
|
43
|
+
}
|
|
44
|
+
if (resp->htresp) {
|
|
45
|
+
res->htcode = resp->htresp->htstatus;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
string row(static_cast<const char*>(resp->row), resp->nrow);
|
|
49
|
+
res->rows.push_back(row);
|
|
50
|
+
}
|
|
51
|
+
res->called = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class QueryUnitTest : public MockUnitTest {
|
|
56
|
+
protected:
|
|
57
|
+
lcb_N1QLPARAMS *params;
|
|
58
|
+
void SetUp() {
|
|
59
|
+
params = lcb_n1p_new();
|
|
60
|
+
}
|
|
61
|
+
void TearDown() {
|
|
62
|
+
lcb_n1p_free(params);
|
|
63
|
+
}
|
|
64
|
+
bool createQueryConnection(HandleWrap& hw, lcb_t& instance) {
|
|
65
|
+
if (MockEnvironment::getInstance()->isRealCluster()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
createConnection(hw, instance);
|
|
69
|
+
const lcbvb_CONFIG *vbc;
|
|
70
|
+
lcb_error_t rc;
|
|
71
|
+
rc = lcb_cntl(instance, LCB_CNTL_GET, LCB_CNTL_VBCONFIG, &vbc);
|
|
72
|
+
EXPECT_EQ(LCB_SUCCESS, rc);
|
|
73
|
+
int ix = lcbvb_get_randhost(vbc, LCBVB_SVCTYPE_N1QL, LCBVB_SVCMODE_PLAIN);
|
|
74
|
+
return ix > -1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void makeCommand(const char *query, lcb_CMDN1QL& cmd, bool prepared=false) {
|
|
78
|
+
lcb_n1p_setstmtz(params, query);
|
|
79
|
+
lcb_error_t rc = lcb_n1p_mkcmd(params, &cmd);
|
|
80
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
81
|
+
|
|
82
|
+
cmd.callback = rowcb;
|
|
83
|
+
if (prepared) {
|
|
84
|
+
cmd.cmdflags |= LCB_CMDN1QL_F_PREPCACHE;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
TEST_F(QueryUnitTest, testSimple)
|
|
90
|
+
{
|
|
91
|
+
lcb_t instance;
|
|
92
|
+
HandleWrap hw;
|
|
93
|
+
if (!createQueryConnection(hw, instance)) {
|
|
94
|
+
SKIP_QUERY_TEST();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
98
|
+
N1QLResult res;
|
|
99
|
+
makeCommand("SELECT mockrow", cmd);
|
|
100
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
101
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
102
|
+
lcb_wait(instance);
|
|
103
|
+
ASSERT_EQ(LCB_SUCCESS, res.rc);
|
|
104
|
+
ASSERT_EQ(1, res.rows.size());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
TEST_F(QueryUnitTest, testQueryError)
|
|
108
|
+
{
|
|
109
|
+
lcb_t instance;
|
|
110
|
+
HandleWrap hw;
|
|
111
|
+
if (!createQueryConnection(hw, instance)) {
|
|
112
|
+
SKIP_QUERY_TEST();
|
|
113
|
+
}
|
|
114
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
115
|
+
N1QLResult res;
|
|
116
|
+
makeCommand("SELECT blahblah FROM blahblah", cmd);
|
|
117
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
118
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
119
|
+
lcb_wait(instance);
|
|
120
|
+
ASSERT_TRUE(res.rows.empty());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
TEST_F(QueryUnitTest, testInvalidJson)
|
|
124
|
+
{
|
|
125
|
+
lcb_t instance;
|
|
126
|
+
HandleWrap hw;
|
|
127
|
+
createConnection(hw, instance);
|
|
128
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
129
|
+
cmd.query = "blahblah";
|
|
130
|
+
cmd.nquery = strlen(cmd.query);
|
|
131
|
+
cmd.callback = rowcb;
|
|
132
|
+
lcb_error_t rc = lcb_n1ql_query(instance, NULL, &cmd);
|
|
133
|
+
ASSERT_NE(LCB_SUCCESS, rc);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
TEST_F(QueryUnitTest, testPrepareOk)
|
|
137
|
+
{
|
|
138
|
+
lcb_t instance;
|
|
139
|
+
HandleWrap hw;
|
|
140
|
+
if (!createQueryConnection(hw, instance)) {
|
|
141
|
+
SKIP_QUERY_TEST();
|
|
142
|
+
}
|
|
143
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
144
|
+
N1QLResult res;
|
|
145
|
+
makeCommand("SELECT mockrow", cmd, true);
|
|
146
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
147
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
148
|
+
lcb_wait(instance);
|
|
149
|
+
ASSERT_EQ(res.rc, LCB_SUCCESS);
|
|
150
|
+
ASSERT_EQ(1, res.rows.size());
|
|
151
|
+
|
|
152
|
+
// Get the plan contents
|
|
153
|
+
string query("SELECT mockrow");
|
|
154
|
+
string plan;
|
|
155
|
+
lcb_n1qlcache_getplan(instance->n1ql_cache, query, plan);
|
|
156
|
+
// We have the plan!
|
|
157
|
+
ASSERT_FALSE(plan.empty());
|
|
158
|
+
|
|
159
|
+
// Issue it again..
|
|
160
|
+
makeCommand("SELECT mockrow", cmd, true);
|
|
161
|
+
res.reset();
|
|
162
|
+
rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
163
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
164
|
+
lcb_wait(instance);
|
|
165
|
+
string plan2;
|
|
166
|
+
lcb_n1qlcache_getplan(instance->n1ql_cache, query, plan2);
|
|
167
|
+
ASSERT_FALSE(plan2.empty());
|
|
168
|
+
ASSERT_EQ(plan, plan2) << "Reused the same query (cache works!)";
|
|
169
|
+
|
|
170
|
+
lcb_n1qlcache_clear(instance->n1ql_cache);
|
|
171
|
+
plan.clear();
|
|
172
|
+
lcb_n1qlcache_getplan(instance->n1ql_cache, query, plan);
|
|
173
|
+
ASSERT_TRUE(plan.empty());
|
|
174
|
+
|
|
175
|
+
// Issue it again!
|
|
176
|
+
makeCommand("SELECT mockrow", cmd, true);
|
|
177
|
+
res.reset();
|
|
178
|
+
rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
179
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
180
|
+
lcb_wait(instance);
|
|
181
|
+
|
|
182
|
+
ASSERT_EQ(1, res.rows.size());
|
|
183
|
+
lcb_n1qlcache_getplan(instance->n1ql_cache, query, plan);
|
|
184
|
+
ASSERT_FALSE(plan.empty());
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
TEST_F(QueryUnitTest, testPrepareStale)
|
|
188
|
+
{
|
|
189
|
+
lcb_t instance;
|
|
190
|
+
HandleWrap hw;
|
|
191
|
+
if (!createQueryConnection(hw, instance)) {
|
|
192
|
+
SKIP_QUERY_TEST();
|
|
193
|
+
}
|
|
194
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
195
|
+
N1QLResult res;
|
|
196
|
+
makeCommand("SELECT mockrow", cmd, true);
|
|
197
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
198
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
199
|
+
lcb_wait(instance);
|
|
200
|
+
ASSERT_EQ(1, res.rows.size());
|
|
201
|
+
|
|
202
|
+
// Reset the index "state"
|
|
203
|
+
MockCommand mcmd(MockCommand::RESET_QUERYSTATE);
|
|
204
|
+
doMockTxn(mcmd);
|
|
205
|
+
|
|
206
|
+
// Ensure the previous plan fails
|
|
207
|
+
string query("SELECT mockrow");
|
|
208
|
+
string raw;
|
|
209
|
+
lcb_n1qlcache_getplan(instance->n1ql_cache, query, raw);
|
|
210
|
+
ASSERT_FALSE(raw.empty());
|
|
211
|
+
|
|
212
|
+
cmd.query = raw.c_str();
|
|
213
|
+
cmd.nquery = raw.size();
|
|
214
|
+
cmd.cmdflags = 0;
|
|
215
|
+
|
|
216
|
+
res.reset();
|
|
217
|
+
rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
218
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
219
|
+
lcb_wait(instance);
|
|
220
|
+
ASSERT_TRUE(res.rows.empty());
|
|
221
|
+
ASSERT_FALSE(res.meta.empty());
|
|
222
|
+
ASSERT_NE(string::npos, res.meta.find("indexNotFound"));
|
|
223
|
+
|
|
224
|
+
// Now that we've verified our current plan isn't working, let's try to
|
|
225
|
+
// issue the cached plan again. lcb should get us a new plan
|
|
226
|
+
makeCommand("SELECT mockrow", cmd , true);
|
|
227
|
+
res.reset();
|
|
228
|
+
rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
229
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
230
|
+
lcb_wait(instance);
|
|
231
|
+
ASSERT_EQ(1, res.rows.size());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
TEST_F(QueryUnitTest, testPrepareFailure)
|
|
235
|
+
{
|
|
236
|
+
lcb_t instance;
|
|
237
|
+
HandleWrap hw;
|
|
238
|
+
if (!createQueryConnection(hw, instance)) {
|
|
239
|
+
SKIP_QUERY_TEST();
|
|
240
|
+
}
|
|
241
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
242
|
+
N1QLResult res;
|
|
243
|
+
makeCommand("SELECT blahblah", cmd, true);
|
|
244
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
245
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
246
|
+
lcb_wait(instance);
|
|
247
|
+
ASSERT_TRUE(res.called);
|
|
248
|
+
ASSERT_NE(LCB_SUCCESS, res.rc);
|
|
249
|
+
ASSERT_TRUE(res.rows.empty());
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
TEST_F(QueryUnitTest, testCancellation)
|
|
253
|
+
{
|
|
254
|
+
lcb_t instance;
|
|
255
|
+
HandleWrap hw;
|
|
256
|
+
if (!createQueryConnection(hw, instance)) {
|
|
257
|
+
SKIP_QUERY_TEST();
|
|
258
|
+
}
|
|
259
|
+
lcb_CMDN1QL cmd = { 0 };
|
|
260
|
+
N1QLResult res;
|
|
261
|
+
makeCommand("SELECT mockrow", cmd);
|
|
262
|
+
lcb_N1QLHANDLE handle = NULL;
|
|
263
|
+
cmd.handle = &handle;
|
|
264
|
+
lcb_error_t rc = lcb_n1ql_query(instance, &res, &cmd);
|
|
265
|
+
ASSERT_EQ(LCB_SUCCESS, rc);
|
|
266
|
+
ASSERT_TRUE(handle != NULL);
|
|
267
|
+
lcb_n1ql_cancel(instance, handle);
|
|
268
|
+
lcb_wait(instance);
|
|
269
|
+
ASSERT_FALSE(res.called);
|
|
270
|
+
}
|
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2012 Couchbase, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
#include "config.h"
|
|
18
|
+
#include "iotests.h"
|
|
19
|
+
#include <map>
|
|
20
|
+
|
|
21
|
+
#include "internal.h" /* vbucket_* things from lcb_t */
|
|
22
|
+
#include <lcbio/iotable.h>
|
|
23
|
+
#include "bucketconfig/bc_http.h"
|
|
24
|
+
|
|
25
|
+
#define LOGARGS(instance, lvl) \
|
|
26
|
+
instance->settings, "tests-MUT", LCB_LOG_##lvl, __FILE__, __LINE__
|
|
27
|
+
|
|
28
|
+
#if defined(_WIN32) && !defined(usleep)
|
|
29
|
+
#define usleep(n) Sleep((n) / 1000)
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
namespace {
|
|
33
|
+
class Retryer {
|
|
34
|
+
public:
|
|
35
|
+
Retryer(time_t maxDuration) : maxDuration(maxDuration) {}
|
|
36
|
+
bool run() {
|
|
37
|
+
time_t maxTime = time(NULL) + maxDuration;
|
|
38
|
+
while (!checkCondition()) {
|
|
39
|
+
trigger();
|
|
40
|
+
if (checkCondition()) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
if (time(NULL) > maxTime) {
|
|
44
|
+
printf("Time expired and condition still false!\n");
|
|
45
|
+
break;
|
|
46
|
+
} else {
|
|
47
|
+
printf("Sleeping for a bit to allow failover/respawn propagation\n");
|
|
48
|
+
usleep(100000); // Sleep for 100ms
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return checkCondition();
|
|
52
|
+
}
|
|
53
|
+
protected:
|
|
54
|
+
virtual bool checkCondition() = 0;
|
|
55
|
+
virtual void trigger() = 0;
|
|
56
|
+
private:
|
|
57
|
+
time_t maxDuration;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
extern "C" {
|
|
61
|
+
static void nopStoreCb(lcb_t, int, const lcb_RESPBASE *) {}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class NumNodeRetryer : public Retryer {
|
|
65
|
+
public:
|
|
66
|
+
NumNodeRetryer(time_t duration, lcb_t instance, size_t expCount) :
|
|
67
|
+
Retryer(duration), instance(instance), expCount(expCount) {
|
|
68
|
+
genDistKeys(LCBT_VBCONFIG(instance), distKeys);
|
|
69
|
+
}
|
|
70
|
+
virtual ~NumNodeRetryer() {}
|
|
71
|
+
|
|
72
|
+
protected:
|
|
73
|
+
virtual bool checkCondition() {
|
|
74
|
+
return lcb_get_num_nodes(instance) == expCount;
|
|
75
|
+
}
|
|
76
|
+
virtual void trigger() {
|
|
77
|
+
lcb_RESPCALLBACK oldCb = lcb_install_callback3(instance, LCB_CALLBACK_STORE, nopStoreCb);
|
|
78
|
+
lcb_CMDSTORE scmd = { 0 };
|
|
79
|
+
scmd.operation = LCB_SET;
|
|
80
|
+
lcb_sched_enter(instance);
|
|
81
|
+
|
|
82
|
+
size_t nSubmit = 0;
|
|
83
|
+
for (size_t ii = 0; ii < distKeys.size(); ii++) {
|
|
84
|
+
LCB_CMD_SET_KEY(&scmd, distKeys[ii].c_str(), distKeys[ii].size());
|
|
85
|
+
LCB_CMD_SET_VALUE(&scmd, distKeys[ii].c_str(), distKeys[ii].size());
|
|
86
|
+
lcb_error_t rc = lcb_store3(instance, NULL, &scmd);
|
|
87
|
+
if (rc != LCB_SUCCESS) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
nSubmit++;
|
|
91
|
+
}
|
|
92
|
+
if (nSubmit) {
|
|
93
|
+
lcb_sched_leave(instance);
|
|
94
|
+
lcb_wait(instance);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
lcb_install_callback3(instance, LCB_CALLBACK_STORE, oldCb);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private:
|
|
101
|
+
lcb_t instance;
|
|
102
|
+
size_t expCount;
|
|
103
|
+
std::vector<std::string> distKeys;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static bool
|
|
108
|
+
syncWithNodeCount_(lcb_t instance, size_t expCount)
|
|
109
|
+
{
|
|
110
|
+
NumNodeRetryer rr(60, instance, expCount);
|
|
111
|
+
return rr.run();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#define SYNC_WITH_NODECOUNT(instance, expCount) \
|
|
115
|
+
if (!syncWithNodeCount_(instance, expCount)) { \
|
|
116
|
+
lcb_log(LOGARGS(instance, WARN), "Timed out waiting for new configuration. Slow system?"); \
|
|
117
|
+
fprintf(stderr, "*** FIXME: TEST NOT RUN! (not an SDK error)\n"); \
|
|
118
|
+
return; \
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
extern "C" {
|
|
124
|
+
static void opFromCallback_storeCB(lcb_t, const void *, lcb_storage_t,
|
|
125
|
+
lcb_error_t error, const lcb_store_resp_t *) {
|
|
126
|
+
ASSERT_EQ(LCB_SUCCESS, error);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static void opFromCallback_statsCB(lcb_t instance, const void *,
|
|
130
|
+
lcb_error_t error, const lcb_server_stat_resp_t *resp)
|
|
131
|
+
{
|
|
132
|
+
lcb_error_t err;
|
|
133
|
+
char *statkey;
|
|
134
|
+
lcb_size_t nstatkey;
|
|
135
|
+
|
|
136
|
+
ASSERT_EQ(0, resp->version);
|
|
137
|
+
const char *server_endpoint = resp->v.v0.server_endpoint;
|
|
138
|
+
const void *key = resp->v.v0.key;
|
|
139
|
+
lcb_size_t nkey = resp->v.v0.nkey;
|
|
140
|
+
const void *bytes = resp->v.v0.bytes;
|
|
141
|
+
lcb_size_t nbytes = resp->v.v0.nbytes;
|
|
142
|
+
|
|
143
|
+
ASSERT_EQ(LCB_SUCCESS, error);
|
|
144
|
+
if (server_endpoint != NULL) {
|
|
145
|
+
nstatkey = strlen(server_endpoint) + nkey + 2;
|
|
146
|
+
statkey = new char[nstatkey];
|
|
147
|
+
snprintf(statkey, nstatkey, "%s-%.*s", server_endpoint,
|
|
148
|
+
(int)nkey, (const char *)key);
|
|
149
|
+
|
|
150
|
+
lcb_store_cmd_t storecmd(LCB_SET, statkey, nstatkey, bytes, nbytes);
|
|
151
|
+
lcb_store_cmd_t *storecmds[] = { &storecmd };
|
|
152
|
+
err = lcb_store(instance, NULL, 1, storecmds);
|
|
153
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
154
|
+
delete []statkey;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
TEST_F(MockUnitTest, testOpFromCallback)
|
|
160
|
+
{
|
|
161
|
+
// @todo we need to have a test that actually tests the timeout callback..
|
|
162
|
+
lcb_t instance;
|
|
163
|
+
HandleWrap hw;
|
|
164
|
+
createConnection(hw, instance);
|
|
165
|
+
|
|
166
|
+
lcb_set_stat_callback(instance, opFromCallback_statsCB);
|
|
167
|
+
lcb_set_store_callback(instance, opFromCallback_storeCB);
|
|
168
|
+
|
|
169
|
+
lcb_server_stats_cmd_t stat;
|
|
170
|
+
lcb_server_stats_cmd_t *commands[] = {&stat };
|
|
171
|
+
|
|
172
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_cntl_string(instance, "operation_timeout", "5.0"));
|
|
173
|
+
ASSERT_EQ(LCB_SUCCESS, lcb_server_stats(instance, NULL, 1, commands));
|
|
174
|
+
lcb_wait(instance);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
struct timeout_test_cookie {
|
|
178
|
+
int *counter;
|
|
179
|
+
lcb_error_t expected;
|
|
180
|
+
};
|
|
181
|
+
extern "C" {
|
|
182
|
+
static void set_callback(lcb_t instance,
|
|
183
|
+
const void *cookie,
|
|
184
|
+
lcb_storage_t, lcb_error_t err,
|
|
185
|
+
const lcb_store_resp_t *)
|
|
186
|
+
{
|
|
187
|
+
timeout_test_cookie *tc = (timeout_test_cookie*)cookie;;
|
|
188
|
+
lcb_log(LOGARGS(instance, INFO), "Got code 0x%x. Expected 0x%x", err, tc->expected);
|
|
189
|
+
EXPECT_EQ(tc->expected, err);
|
|
190
|
+
if (err == LCB_ETIMEDOUT) {
|
|
191
|
+
// Remove the hiccup at the first timeout failure
|
|
192
|
+
MockEnvironment::getInstance()->hiccupNodes(0, 0);
|
|
193
|
+
}
|
|
194
|
+
*tc->counter -= 1;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
struct next_store_st {
|
|
198
|
+
lcb_t instance;
|
|
199
|
+
struct timeout_test_cookie *tc;
|
|
200
|
+
const lcb_store_cmd_t * const * cmdpp;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
static void reschedule_callback(void *cookie)
|
|
204
|
+
{
|
|
205
|
+
lcb_error_t err;
|
|
206
|
+
struct next_store_st *ns = (struct next_store_st *)cookie;
|
|
207
|
+
lcb_log(LOGARGS(ns->instance, INFO), "Rescheduling operation..");
|
|
208
|
+
err = lcb_store(ns->instance, ns->tc, 1, ns->cmdpp);
|
|
209
|
+
lcb_loop_unref(ns->instance);
|
|
210
|
+
EXPECT_EQ(LCB_SUCCESS, err);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
TEST_F(MockUnitTest, testTimeoutOnlyStale)
|
|
216
|
+
{
|
|
217
|
+
SKIP_UNLESS_MOCK();
|
|
218
|
+
|
|
219
|
+
HandleWrap hw;
|
|
220
|
+
createConnection(hw);
|
|
221
|
+
lcb_t instance = hw.getLcb();
|
|
222
|
+
lcb_uint32_t tmoval = 1000000;
|
|
223
|
+
int nremaining = 2;
|
|
224
|
+
struct timeout_test_cookie cookies[2];
|
|
225
|
+
MockEnvironment *mock = MockEnvironment::getInstance();
|
|
226
|
+
|
|
227
|
+
// Set the timeout
|
|
228
|
+
lcb_cntl(instance, LCB_CNTL_SET, LCB_CNTL_OP_TIMEOUT, &tmoval);
|
|
229
|
+
|
|
230
|
+
lcb_set_store_callback(instance, set_callback);
|
|
231
|
+
|
|
232
|
+
lcb_store_cmd_t scmd, *cmdp;
|
|
233
|
+
const char *key = "i'm a key";
|
|
234
|
+
const char *value = "a value";
|
|
235
|
+
cmdp = &scmd;
|
|
236
|
+
|
|
237
|
+
removeKey(instance, key);
|
|
238
|
+
|
|
239
|
+
// Make the mock timeout the first cookie. The extras length is:
|
|
240
|
+
mock->hiccupNodes(1500, 1);
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
memset(&scmd, 0, sizeof(scmd));
|
|
245
|
+
scmd.v.v0.key = key;
|
|
246
|
+
scmd.v.v0.nkey = strlen(key);
|
|
247
|
+
scmd.v.v0.bytes = value;
|
|
248
|
+
scmd.v.v0.nbytes = strlen(value);
|
|
249
|
+
scmd.v.v0.operation = LCB_SET;
|
|
250
|
+
cookies[0].counter = &nremaining;
|
|
251
|
+
cookies[0].expected = LCB_ETIMEDOUT;
|
|
252
|
+
lcb_store(instance, cookies, 1, &cmdp);
|
|
253
|
+
|
|
254
|
+
cookies[1].counter = &nremaining;
|
|
255
|
+
cookies[1].expected = LCB_SUCCESS;
|
|
256
|
+
struct next_store_st ns;
|
|
257
|
+
ns.cmdpp = &cmdp;
|
|
258
|
+
ns.tc = cookies+1;
|
|
259
|
+
ns.instance = instance;
|
|
260
|
+
lcbio_pTIMER timer = lcbio_timer_new(instance->iotable, &ns, reschedule_callback);
|
|
261
|
+
lcb_loop_ref(instance);
|
|
262
|
+
lcbio_timer_rearm(timer, 900000);
|
|
263
|
+
|
|
264
|
+
lcb_log(LOGARGS(instance, INFO), "Waiting..");
|
|
265
|
+
lcb_wait(instance);
|
|
266
|
+
lcbio_timer_destroy(timer);
|
|
267
|
+
|
|
268
|
+
ASSERT_EQ(0, nremaining);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
extern "C" {
|
|
273
|
+
struct rvbuf {
|
|
274
|
+
lcb_error_t error;
|
|
275
|
+
lcb_cas_t cas1;
|
|
276
|
+
lcb_cas_t cas2;
|
|
277
|
+
char *bytes;
|
|
278
|
+
lcb_size_t nbytes;
|
|
279
|
+
lcb_int32_t counter;
|
|
280
|
+
};
|
|
281
|
+
int store_cnt;
|
|
282
|
+
|
|
283
|
+
/* Needed for "testPurgedBody", to ensure preservation of connection */
|
|
284
|
+
static void io_close_wrap(lcb_io_opt_t, lcb_socket_t)
|
|
285
|
+
{
|
|
286
|
+
fprintf(stderr, "We requested to close, but we were't expecting it\n");
|
|
287
|
+
abort();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
static void store_callback(lcb_t instance, const void *cookie,
|
|
291
|
+
lcb_storage_t, lcb_error_t error,
|
|
292
|
+
const lcb_store_resp_t *)
|
|
293
|
+
{
|
|
294
|
+
struct rvbuf *rv = (struct rvbuf *)cookie;
|
|
295
|
+
lcb_log(LOGARGS(instance, INFO),
|
|
296
|
+
"Got storage callback for cookie %p with err=0x%x",
|
|
297
|
+
(void *)cookie,
|
|
298
|
+
(int)error);
|
|
299
|
+
|
|
300
|
+
rv->error = error;
|
|
301
|
+
store_cnt++;
|
|
302
|
+
if (!instance->wait) { /* do not touch IO if we are using lcb_wait() */
|
|
303
|
+
lcb_stop_loop(instance);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
static void get_callback(lcb_t instance, const void *cookie,
|
|
308
|
+
lcb_error_t error, const lcb_get_resp_t *resp)
|
|
309
|
+
{
|
|
310
|
+
struct rvbuf *rv = (struct rvbuf *)cookie;
|
|
311
|
+
rv->error = error;
|
|
312
|
+
rv->bytes = (char *)malloc(resp->v.v0.nbytes);
|
|
313
|
+
memcpy((void *)rv->bytes, resp->v.v0.bytes, resp->v.v0.nbytes);
|
|
314
|
+
rv->nbytes = resp->v.v0.nbytes;
|
|
315
|
+
if (!instance->wait) { /* do not touch IO if we are using lcb_wait() */
|
|
316
|
+
lcb_stop_loop(instance);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
struct StoreContext {
|
|
322
|
+
std::map<std::string, lcb_error_t> mm;
|
|
323
|
+
typedef std::map<std::string, lcb_error_t>::iterator MyIter;
|
|
324
|
+
|
|
325
|
+
void check(int expected) {
|
|
326
|
+
EXPECT_EQ(expected, mm.size());
|
|
327
|
+
|
|
328
|
+
for (MyIter iter = mm.begin(); iter != mm.end(); iter++) {
|
|
329
|
+
EXPECT_EQ(LCB_SUCCESS, iter->second);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
void clear() {
|
|
334
|
+
mm.clear();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
extern "C" {
|
|
339
|
+
static void ctx_store_callback(lcb_t, const void *cookie, lcb_storage_t,
|
|
340
|
+
lcb_error_t err, const lcb_store_resp_t *resp)
|
|
341
|
+
{
|
|
342
|
+
StoreContext *ctx = reinterpret_cast<StoreContext *>(
|
|
343
|
+
const_cast<void *>(cookie));
|
|
344
|
+
|
|
345
|
+
std::string s((const char *)resp->v.v0.key, resp->v.v0.nkey);
|
|
346
|
+
ctx->mm[s] = err;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
TEST_F(MockUnitTest, testReconfigurationOnNodeFailover)
|
|
351
|
+
{
|
|
352
|
+
SKIP_UNLESS_MOCK();
|
|
353
|
+
lcb_t instance;
|
|
354
|
+
HandleWrap hw;
|
|
355
|
+
lcb_error_t err;
|
|
356
|
+
const char *argv[] = { "--replicas", "0", "--nodes", "4", NULL };
|
|
357
|
+
|
|
358
|
+
MockEnvironment mock_o(argv), *mock = &mock_o;
|
|
359
|
+
|
|
360
|
+
std::vector<std::string> keys;
|
|
361
|
+
std::vector<lcb_store_cmd_t> cmds;
|
|
362
|
+
std::vector<lcb_store_cmd_t *>ppcmds;
|
|
363
|
+
|
|
364
|
+
mock->createConnection(hw, instance);
|
|
365
|
+
instance->settings->vb_noguess = 1;
|
|
366
|
+
lcb_connect(instance);
|
|
367
|
+
lcb_wait(instance);
|
|
368
|
+
ASSERT_EQ(0, lcb_get_num_replicas(instance));
|
|
369
|
+
|
|
370
|
+
size_t numNodes = mock->getNumNodes();
|
|
371
|
+
|
|
372
|
+
genDistKeys(LCBT_VBCONFIG(instance), keys);
|
|
373
|
+
genStoreCommands(keys, cmds, ppcmds);
|
|
374
|
+
StoreContext ctx;
|
|
375
|
+
|
|
376
|
+
mock->failoverNode(0);
|
|
377
|
+
SYNC_WITH_NODECOUNT(instance, numNodes-1);
|
|
378
|
+
|
|
379
|
+
lcb_set_store_callback(instance, ctx_store_callback);
|
|
380
|
+
err = lcb_store(instance, &ctx, cmds.size(), &ppcmds[0]);
|
|
381
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
382
|
+
lcb_wait(instance);
|
|
383
|
+
ctx.check((int)cmds.size());
|
|
384
|
+
|
|
385
|
+
mock->respawnNode(0);
|
|
386
|
+
SYNC_WITH_NODECOUNT(instance, numNodes);
|
|
387
|
+
|
|
388
|
+
ctx.clear();
|
|
389
|
+
err = lcb_store(instance, &ctx, cmds.size(), &ppcmds[0]);
|
|
390
|
+
lcb_wait(instance);
|
|
391
|
+
ctx.check((int)cmds.size());
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
struct fo_context_st {
|
|
397
|
+
MockEnvironment *env;
|
|
398
|
+
int index;
|
|
399
|
+
lcb_t instance;
|
|
400
|
+
};
|
|
401
|
+
// Hiccup the server, then fail it over.
|
|
402
|
+
extern "C" {
|
|
403
|
+
static void fo_callback(void *cookie)
|
|
404
|
+
{
|
|
405
|
+
fo_context_st *ctx = (fo_context_st *)cookie;
|
|
406
|
+
ctx->env->failoverNode(ctx->index);
|
|
407
|
+
ctx->env->hiccupNodes(0, 0);
|
|
408
|
+
lcb_loop_unref(ctx->instance);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
TEST_F(MockUnitTest, testBufferRelocationOnNodeFailover)
|
|
413
|
+
{
|
|
414
|
+
SKIP_UNLESS_MOCK();
|
|
415
|
+
lcb_error_t err;
|
|
416
|
+
struct rvbuf rv;
|
|
417
|
+
lcb_t instance;
|
|
418
|
+
HandleWrap hw;
|
|
419
|
+
std::string key = "testBufferRelocationOnNodeFailover";
|
|
420
|
+
std::string val = "foo";
|
|
421
|
+
|
|
422
|
+
const char *argv[] = { "--replicas", "0", "--nodes", "4", NULL };
|
|
423
|
+
MockEnvironment mock_o(argv), *mock = &mock_o;
|
|
424
|
+
|
|
425
|
+
// We need to disable CCCP for this test to receive "Push" style
|
|
426
|
+
// configuration.
|
|
427
|
+
mock->setCCCP(false);
|
|
428
|
+
|
|
429
|
+
mock->createConnection(hw, instance);
|
|
430
|
+
lcb_connect(instance);
|
|
431
|
+
lcb_wait(instance);
|
|
432
|
+
|
|
433
|
+
// Set the timeout for 15 seconds
|
|
434
|
+
lcb_uint32_t tmoval = 15000000;
|
|
435
|
+
lcb_cntl(instance, LCB_CNTL_SET, LCB_CNTL_OP_TIMEOUT, &tmoval);
|
|
436
|
+
|
|
437
|
+
lcb_set_store_callback(instance, store_callback);
|
|
438
|
+
lcb_set_get_callback(instance, get_callback);
|
|
439
|
+
|
|
440
|
+
// Initialize the nodes first..
|
|
441
|
+
removeKey(instance, key);
|
|
442
|
+
|
|
443
|
+
/* Schedule SET operation */
|
|
444
|
+
lcb_store_cmd_t storecmd(LCB_SET, key.c_str(), key.size(),
|
|
445
|
+
val.c_str(), val.size());
|
|
446
|
+
|
|
447
|
+
/* Determine what server should receive that operation */
|
|
448
|
+
int vb, idx;
|
|
449
|
+
lcbvb_map_key(LCBT_VBCONFIG(instance), key.c_str(), key.size(), &vb, &idx);
|
|
450
|
+
mock->hiccupNodes(5000, 1);
|
|
451
|
+
|
|
452
|
+
struct fo_context_st ctx = { mock, idx, instance };
|
|
453
|
+
lcbio_pTIMER timer;
|
|
454
|
+
timer = lcbio_timer_new(instance->iotable, &ctx, fo_callback);
|
|
455
|
+
lcb_loop_ref(instance);
|
|
456
|
+
lcbio_timer_rearm(timer, 500000);
|
|
457
|
+
|
|
458
|
+
lcb_store_cmd_t *storecmds[] = { &storecmd };
|
|
459
|
+
err = lcb_store(instance, &rv, 1, storecmds);
|
|
460
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
461
|
+
|
|
462
|
+
store_cnt = 0;
|
|
463
|
+
lcb_wait(instance);
|
|
464
|
+
ASSERT_EQ(1, store_cnt);
|
|
465
|
+
ASSERT_EQ(LCB_SUCCESS, rv.error);
|
|
466
|
+
|
|
467
|
+
memset(&rv, 0, sizeof(rv));
|
|
468
|
+
err = lcb_store(instance, &rv, 1, storecmds);
|
|
469
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
470
|
+
store_cnt = 0;
|
|
471
|
+
lcb_wait(instance);
|
|
472
|
+
ASSERT_EQ(1, store_cnt);
|
|
473
|
+
|
|
474
|
+
/* Check that value was actually set */
|
|
475
|
+
lcb_get_cmd_t getcmd(key.c_str(), key.size());
|
|
476
|
+
lcb_get_cmd_t *getcmds[] = { &getcmd };
|
|
477
|
+
err = lcb_get(instance, &rv, 1, getcmds);
|
|
478
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
479
|
+
|
|
480
|
+
lcb_wait(instance);
|
|
481
|
+
lcbio_timer_destroy(timer);
|
|
482
|
+
ASSERT_EQ(LCB_SUCCESS, rv.error);
|
|
483
|
+
ASSERT_EQ(rv.nbytes, val.size());
|
|
484
|
+
std::string bytes = std::string(rv.bytes, rv.nbytes);
|
|
485
|
+
ASSERT_STREQ(bytes.c_str(), val.c_str());
|
|
486
|
+
free(rv.bytes);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
TEST_F(MockUnitTest, testSaslMechs)
|
|
490
|
+
{
|
|
491
|
+
// Ensure our SASL mech listing works.
|
|
492
|
+
SKIP_UNLESS_MOCK();
|
|
493
|
+
|
|
494
|
+
const char *argv[] = { "--buckets", "protected:secret:couchbase", NULL };
|
|
495
|
+
|
|
496
|
+
lcb_t instance;
|
|
497
|
+
lcb_error_t err;
|
|
498
|
+
struct lcb_create_st crParams;
|
|
499
|
+
MockEnvironment mock_o(argv, "protected"), *protectedEnv = &mock_o;
|
|
500
|
+
protectedEnv->makeConnectParams(crParams, NULL);
|
|
501
|
+
protectedEnv->setCCCP(false);
|
|
502
|
+
|
|
503
|
+
crParams.v.v0.user = "protected";
|
|
504
|
+
crParams.v.v0.passwd = "secret";
|
|
505
|
+
crParams.v.v0.bucket = "protected";
|
|
506
|
+
doLcbCreate(&instance, &crParams, protectedEnv);
|
|
507
|
+
|
|
508
|
+
// Make the socket pool disallow idle connections
|
|
509
|
+
instance->memd_sockpool->maxidle = 0;
|
|
510
|
+
|
|
511
|
+
err = lcb_connect(instance);
|
|
512
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
513
|
+
lcb_wait(instance);
|
|
514
|
+
|
|
515
|
+
// Force our SASL mech
|
|
516
|
+
err = lcb_cntl(instance, LCB_CNTL_SET,
|
|
517
|
+
LCB_CNTL_FORCE_SASL_MECH, (void *)"blah");
|
|
518
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
519
|
+
|
|
520
|
+
Item itm("key", "value");
|
|
521
|
+
KVOperation kvo(&itm);
|
|
522
|
+
|
|
523
|
+
kvo.allowableErrors.insert(LCB_SASLMECH_UNAVAILABLE);
|
|
524
|
+
kvo.allowableErrors.insert(LCB_ETIMEDOUT);
|
|
525
|
+
kvo.store(instance);
|
|
526
|
+
|
|
527
|
+
ASSERT_FALSE(kvo.globalErrors.find(LCB_SASLMECH_UNAVAILABLE) ==
|
|
528
|
+
kvo.globalErrors.end());
|
|
529
|
+
|
|
530
|
+
err = lcb_cntl(instance, LCB_CNTL_SET,
|
|
531
|
+
LCB_CNTL_FORCE_SASL_MECH, (void *)"PLAIN");
|
|
532
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
533
|
+
|
|
534
|
+
kvo.clear();
|
|
535
|
+
kvo.store(instance);
|
|
536
|
+
|
|
537
|
+
lcb_destroy(instance);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
static void
|
|
541
|
+
doManyItems(lcb_t instance, std::vector<std::string> keys)
|
|
542
|
+
{
|
|
543
|
+
lcb_CMDSTORE cmd = { 0 };
|
|
544
|
+
cmd.operation = LCB_SET;
|
|
545
|
+
lcb_sched_enter(instance);
|
|
546
|
+
for (size_t ii = 0; ii < keys.size(); ii++) {
|
|
547
|
+
LCB_CMD_SET_KEY(&cmd, keys[ii].c_str(), keys[ii].size());
|
|
548
|
+
LCB_CMD_SET_VALUE(&cmd, keys[ii].c_str(), keys[ii].size());
|
|
549
|
+
EXPECT_EQ(LCB_SUCCESS, lcb_store3(instance, NULL, &cmd));
|
|
550
|
+
}
|
|
551
|
+
lcb_sched_leave(instance);
|
|
552
|
+
lcb_wait(instance);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
extern "C" {
|
|
556
|
+
static void mcdFoVerifyCb(lcb_t, int, const lcb_RESPBASE *rb)
|
|
557
|
+
{
|
|
558
|
+
EXPECT_EQ(LCB_SUCCESS, rb->rc);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
TEST_F(MockUnitTest, DISABLED_testMemcachedFailover)
|
|
563
|
+
{
|
|
564
|
+
SKIP_UNLESS_MOCK();
|
|
565
|
+
const char *argv[] = { "--buckets", "cache::memcache", NULL };
|
|
566
|
+
lcb_t instance;
|
|
567
|
+
struct lcb_create_st crParams;
|
|
568
|
+
lcb_RESPCALLBACK oldCb;
|
|
569
|
+
|
|
570
|
+
MockEnvironment mock_o(argv, "cache"), *mock = &mock_o;
|
|
571
|
+
mock->makeConnectParams(crParams, NULL);
|
|
572
|
+
doLcbCreate(&instance, &crParams, mock);
|
|
573
|
+
|
|
574
|
+
// Check internal setting here
|
|
575
|
+
lcb_connect(instance);
|
|
576
|
+
lcb_wait(instance);
|
|
577
|
+
size_t numNodes = mock->getNumNodes();
|
|
578
|
+
|
|
579
|
+
oldCb = lcb_install_callback3(instance, LCB_CALLBACK_STORE, mcdFoVerifyCb);
|
|
580
|
+
|
|
581
|
+
// Get the command list:
|
|
582
|
+
std::vector<std::string> distKeys;
|
|
583
|
+
genDistKeys(LCBT_VBCONFIG(instance), distKeys);
|
|
584
|
+
doManyItems(instance, distKeys);
|
|
585
|
+
// Should succeed implicitly with callback above
|
|
586
|
+
|
|
587
|
+
// Fail over the first node..
|
|
588
|
+
mock->failoverNode(1, "cache");
|
|
589
|
+
SYNC_WITH_NODECOUNT(instance, numNodes-1);
|
|
590
|
+
|
|
591
|
+
// Set the callback to the previous one. We expect failures here
|
|
592
|
+
lcb_install_callback3(instance, LCB_CALLBACK_STORE, oldCb);
|
|
593
|
+
doManyItems(instance, distKeys);
|
|
594
|
+
|
|
595
|
+
mock->respawnNode(1, "cache");
|
|
596
|
+
SYNC_WITH_NODECOUNT(instance, numNodes);
|
|
597
|
+
ASSERT_EQ(numNodes, lcb_get_num_nodes(instance));
|
|
598
|
+
|
|
599
|
+
// Restore the verify callback
|
|
600
|
+
lcb_install_callback3(instance, LCB_CALLBACK_STORE, mcdFoVerifyCb);
|
|
601
|
+
doManyItems(instance, distKeys);
|
|
602
|
+
|
|
603
|
+
lcb_destroy(instance);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
struct NegativeIx {
|
|
607
|
+
lcb_error_t err;
|
|
608
|
+
int callCount;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
extern "C" {
|
|
612
|
+
static void get_callback3(lcb_t, int, const lcb_RESPBASE *resp)
|
|
613
|
+
{
|
|
614
|
+
NegativeIx *ni = (NegativeIx *)resp->cookie;
|
|
615
|
+
ni->err = resp->rc;
|
|
616
|
+
ni->callCount++;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* This tests the case where a negative index appears for a vbucket ID for the
|
|
621
|
+
* mapped key. In this case we'd expect that the command would be retried
|
|
622
|
+
* at least once, and not receive an LCB_NO_MATCHING_SERVER.
|
|
623
|
+
*
|
|
624
|
+
* Unfortunately this test is a bit hacky since we need to modify the vbucket
|
|
625
|
+
* information, and hopefully get a new config afterwards. Additionally we'd
|
|
626
|
+
* want to mod
|
|
627
|
+
*/
|
|
628
|
+
TEST_F(MockUnitTest, testNegativeIndex)
|
|
629
|
+
{
|
|
630
|
+
HandleWrap hw;
|
|
631
|
+
lcb_t instance;
|
|
632
|
+
createConnection(hw, instance);
|
|
633
|
+
lcb_install_callback3(instance, LCB_CALLBACK_GET, get_callback3);
|
|
634
|
+
std::string key("ni_key");
|
|
635
|
+
// Get the config
|
|
636
|
+
lcbvb_CONFIG *vbc = instance->cur_configinfo->vbc;
|
|
637
|
+
int vb = lcbvb_k2vb(vbc, key.c_str(), key.size());
|
|
638
|
+
|
|
639
|
+
// Set the index to -1
|
|
640
|
+
vbc->vbuckets[vb].servers[0] = -1;
|
|
641
|
+
NegativeIx ni = { LCB_SUCCESS };
|
|
642
|
+
lcb_CMDGET gcmd = { 0 };
|
|
643
|
+
LCB_CMD_SET_KEY(&gcmd, key.c_str(), key.size());
|
|
644
|
+
// Set the timeout to something a bit shorter
|
|
645
|
+
lcb_cntl_setu32(instance, LCB_CNTL_OP_TIMEOUT, 500000);
|
|
646
|
+
|
|
647
|
+
lcb_sched_enter(instance);
|
|
648
|
+
lcb_error_t err = lcb_get3(instance, &ni, &gcmd);
|
|
649
|
+
ASSERT_EQ(LCB_SUCCESS, err);
|
|
650
|
+
lcb_sched_leave(instance);
|
|
651
|
+
lcb_wait(instance);
|
|
652
|
+
ASSERT_EQ(1, ni.callCount);
|
|
653
|
+
// That's it
|
|
654
|
+
}
|