mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'sharding' of https://github.com/triAGENS/ArangoDB into sharding
This commit is contained in:
commit
e815cc2ae5
|
@ -0,0 +1,276 @@
|
|||
# coding: utf-8
|
||||
|
||||
require 'rspec'
|
||||
require './arangodb.rb'
|
||||
|
||||
describe ArangoDB do
|
||||
api = "/_api/simple"
|
||||
prefix = "api-simple"
|
||||
|
||||
context "simple queries:" do
|
||||
|
||||
################################################################################
|
||||
## range query
|
||||
################################################################################
|
||||
|
||||
context "hash query:" do
|
||||
before do
|
||||
@cn = "UnitTestsCollectionHash"
|
||||
ArangoDB.drop_collection(@cn)
|
||||
@cid = ArangoDB.create_collection(@cn, false)
|
||||
end
|
||||
|
||||
after do
|
||||
ArangoDB.drop_collection(@cn)
|
||||
end
|
||||
|
||||
it "finds the examples, wrong index specified" do
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"1\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(404)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['code'].should eq(404)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(1209)
|
||||
end
|
||||
|
||||
it "finds the examples, wrong attribute" do
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(404)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['code'].should eq(404)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(1209)
|
||||
end
|
||||
|
||||
it "finds the examples, no index specified" do
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples, unique index" do
|
||||
# create data
|
||||
for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
|
||||
body = "{ \"i\" : #{i} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-hash
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 3 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [3]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples, non-unique index" do
|
||||
# create data
|
||||
for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
|
||||
body = "{ \"i\" : #{i}, \"j\" : 2 }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"j\", \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-hash
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 2, \"i\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [2]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [2]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 2, \"j\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [2]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [2]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 3, \"i\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples" do
|
||||
# create data
|
||||
|
||||
(0..10).each do |i|
|
||||
(0..10).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\", \"j\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-hash
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1, \"j\" : 7 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [1]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [7]
|
||||
end
|
||||
|
||||
it "finds the examples, multiple elements" do
|
||||
# create data
|
||||
|
||||
(0..9).each do |i|
|
||||
(0..9).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-hash
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(10)
|
||||
doc.parsed_response['count'].should eq(10)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [1,1,1,1,1,1,1,1,1,1]
|
||||
end
|
||||
|
||||
it "finds the examples, small batchsize" do
|
||||
# create data
|
||||
|
||||
(0..9).each do |i|
|
||||
(0..9).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"hash\", \"unique\" : false, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-hash-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-hash
|
||||
cmd = api + "/by-example-hash"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 0 }, \"batchSize\" : 2 }"
|
||||
doc = ArangoDB.log_put("#{prefix}-hash", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(true)
|
||||
doc.parsed_response['result'].length.should eq(2)
|
||||
doc.parsed_response['count'].should eq(10)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [0,0]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,276 @@
|
|||
# coding: utf-8
|
||||
|
||||
require 'rspec'
|
||||
require './arangodb.rb'
|
||||
|
||||
describe ArangoDB do
|
||||
api = "/_api/simple"
|
||||
prefix = "api-simple"
|
||||
|
||||
context "simple queries:" do
|
||||
|
||||
################################################################################
|
||||
## range query
|
||||
################################################################################
|
||||
|
||||
context "skiplist query:" do
|
||||
before do
|
||||
@cn = "UnitTestsCollectionSkiplist"
|
||||
ArangoDB.drop_collection(@cn)
|
||||
@cid = ArangoDB.create_collection(@cn, false)
|
||||
end
|
||||
|
||||
after do
|
||||
ArangoDB.drop_collection(@cn)
|
||||
end
|
||||
|
||||
it "finds the examples, wrong index specified" do
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"1\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(404)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['code'].should eq(404)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(1209)
|
||||
end
|
||||
|
||||
it "finds the examples, wrong attribute" do
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : true, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(404)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['code'].should eq(404)
|
||||
doc.parsed_response['error'].should eq(true)
|
||||
doc.parsed_response['errorNum'].should eq(1209)
|
||||
end
|
||||
|
||||
it "finds the examples, no index specified" do
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples, unique index" do
|
||||
# create data
|
||||
for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
|
||||
body = "{ \"i\" : #{i} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : true, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-skiplist
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 3 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [3]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 12 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples, non-unique index" do
|
||||
# create data
|
||||
for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
|
||||
body = "{ \"i\" : #{i}, \"j\" : 2 }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"j\", \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-skiplist
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 2, \"i\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [2]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [2]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 2, \"j\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [2]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [2]
|
||||
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"j\" : 3, \"i\" : 2 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(0)
|
||||
doc.parsed_response['count'].should eq(0)
|
||||
end
|
||||
|
||||
it "finds the examples" do
|
||||
# create data
|
||||
|
||||
(0..10).each do |i|
|
||||
(0..10).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\", \"j\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-skiplist
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1, \"j\" : 7 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(1)
|
||||
doc.parsed_response['count'].should eq(1)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [1]
|
||||
doc.parsed_response['result'].map{|i| i['j']}.should =~ [7]
|
||||
end
|
||||
|
||||
it "finds the examples, multiple elements" do
|
||||
# create data
|
||||
|
||||
(0..9).each do |i|
|
||||
(0..9).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-skiplist
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 1 } }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(false)
|
||||
doc.parsed_response['result'].length.should eq(10)
|
||||
doc.parsed_response['count'].should eq(10)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [1,1,1,1,1,1,1,1,1,1]
|
||||
end
|
||||
|
||||
it "finds the examples, small batchsize" do
|
||||
# create data
|
||||
|
||||
(0..9).each do |i|
|
||||
(0..9).each do |j|
|
||||
body = "{ \"i\" : #{i}, \"j\" : #{j} }"
|
||||
doc = ArangoDB.post("/_api/document?collection=#{@cn}", :body => body)
|
||||
doc.code.should eq(202)
|
||||
end
|
||||
end
|
||||
|
||||
# create index
|
||||
cmd = "/_api/index?collection=#{@cn}"
|
||||
body = "{ \"type\" : \"skiplist\", \"unique\" : false, \"fields\" : [ \"i\" ] }"
|
||||
doc = ArangoDB.log_post("#{prefix}-skiplist-index", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
iid = doc.parsed_response['id']
|
||||
|
||||
# by-example-skiplist
|
||||
cmd = api + "/by-example-skiplist"
|
||||
body = "{ \"collection\" : \"#{@cn}\", \"index\" : \"#{iid}\", \"example\" : { \"i\" : 0 }, \"batchSize\" : 2 }"
|
||||
doc = ArangoDB.log_put("#{prefix}-skiplist", cmd, :body => body)
|
||||
|
||||
doc.code.should eq(201)
|
||||
doc.headers['content-type'].should eq("application/json; charset=utf-8")
|
||||
doc.parsed_response['error'].should eq(false)
|
||||
doc.parsed_response['code'].should eq(201)
|
||||
doc.parsed_response['hasMore'].should eq(true)
|
||||
doc.parsed_response['result'].length.should eq(2)
|
||||
doc.parsed_response['count'].should eq(10)
|
||||
doc.parsed_response['result'].map{|i| i['i']}.should =~ [0,0]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -34,7 +34,9 @@ rspec --color --format d \
|
|||
api-simple-example-spec.rb \
|
||||
api-simple-fulltext-spec.rb \
|
||||
api-simple-geo-spec.rb \
|
||||
api-simple-hash-spec.rb \
|
||||
api-simple-range-spec.rb \
|
||||
api-simple-skiplist-spec.rb \
|
||||
api-simple-spec.rb \
|
||||
api-structures.rb \
|
||||
api-transactions-spec.rb \
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
_.each(list, function(url, k) {
|
||||
var v = {};
|
||||
v.name = k;
|
||||
v.url = url;
|
||||
v.address = url;
|
||||
resList.push(v);
|
||||
if (_.contains(noBeat, k)) {
|
||||
v.status = "critical";
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
<meta name="description" content="ArangoDB Cluster Interface">
|
||||
<meta name="author" content="Florian Bartels, Michael Hackstein">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<link href="css/planner.css" rel="stylesheet">
|
||||
<link href="css/cluster.css" rel="stylesheet">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
<script src="sharedLibs.js"></script>
|
||||
<script src="libs.js"></script>
|
||||
<script src="cluster.js"></script>
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, Backbone, window */
|
||||
window.ClusterStatisticsCollection = Backbone.Collection.extend({
|
||||
model: window.Statistics,
|
||||
url: "/_admin/statistics",
|
||||
fetch: function() {
|
||||
this.forEach(function (m) {
|
||||
m.fetch({async: false});
|
||||
})
|
||||
}
|
||||
});
|
|
@ -13,6 +13,20 @@
|
|||
this.interval = 1000;
|
||||
},
|
||||
|
||||
byAddress: function (res) {
|
||||
this.fetch({
|
||||
async: false
|
||||
});
|
||||
res = res || {};
|
||||
this.forEach(function(m) {
|
||||
var addr = m.get("address");
|
||||
addr = addr.substr(6);
|
||||
addr = addr.split(":")[0];
|
||||
res[addr] = res[addr] || [];
|
||||
res[addr].push(m);
|
||||
});
|
||||
},
|
||||
|
||||
getList: function() {
|
||||
this.fetch({
|
||||
async: false
|
||||
|
|
|
@ -16,6 +16,21 @@
|
|||
this.interval = 1000;
|
||||
},
|
||||
|
||||
byAddress: function (res) {
|
||||
this.fetch({
|
||||
async: false
|
||||
});
|
||||
res = res || {};
|
||||
this.forEach(function(m) {
|
||||
var addr = m.get("address");
|
||||
addr = addr.substr(6);
|
||||
addr = addr.split(":")[0];
|
||||
res[addr] = res[addr] || [];
|
||||
res[addr].push(m);
|
||||
});
|
||||
return res;
|
||||
},
|
||||
|
||||
getList: function() {
|
||||
this.fetch({
|
||||
async: false
|
||||
|
|
|
@ -6,5 +6,4 @@
|
|||
<svg id="clusterLayout" height="400px"></svg>
|
||||
<div id="clusterGraphs">
|
||||
|
||||
|
||||
</div>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
this.coordinators.fetch({
|
||||
async : false
|
||||
});
|
||||
this.data = [];
|
||||
if (this.statisticsDescription === undefined) {
|
||||
this.statisticsDescription = new window.StatisticsDescription();
|
||||
this.statisticsDescription.fetch({
|
||||
|
@ -27,20 +26,92 @@
|
|||
});
|
||||
}
|
||||
var self = this;
|
||||
this.dbservers.forEach(function (server) {
|
||||
var statCollect = new window.StatisticsCollection();
|
||||
statCollect.url = server.get("address").replace("tcp", "http") + "/_admin/statistics";
|
||||
self.data.push(statCollect);
|
||||
statCollect.fetch();
|
||||
var statCollect = new window.ClusterStatisticsCollection();
|
||||
this.dbservers.forEach(function (dbserver) {
|
||||
var stat = new window.Statistics({name: dbserver.id});
|
||||
stat.url = dbserver.get("address").replace("tcp", "http") + "/_admin/statistics";
|
||||
statCollect.add(stat);
|
||||
});
|
||||
|
||||
this.coordinators.forEach(function (coordinator) {
|
||||
var stat = new window.Statistics({name: coordinator.id});
|
||||
stat.url = coordinator.get("address").replace("tcp", "http") + "/_admin/statistics";
|
||||
statCollect.add(stat);
|
||||
});
|
||||
statCollect.fetch();
|
||||
this.data = statCollect;
|
||||
|
||||
var byAddress = this.dbservers.byAddress();
|
||||
byAddress = this.coordinators.byAddress(byAddress);
|
||||
console.log(byAddress);
|
||||
},
|
||||
|
||||
|
||||
|
||||
render: function() {
|
||||
console.log(this.data);
|
||||
console.log(this.coordinators.getOverview());
|
||||
var self = this;
|
||||
$(this.el).html(this.template.render({}));
|
||||
}
|
||||
var totalTimeData = [];
|
||||
this.data.forEach(function(m) {
|
||||
totalTimeData.push({key: m.get("name"), value :m.get("client").totalTime.sum});
|
||||
});
|
||||
self.renderPieChart(totalTimeData);
|
||||
},
|
||||
|
||||
|
||||
|
||||
renderPieChart: function(dataset) {
|
||||
var w = 620;
|
||||
var h = 480;
|
||||
|
||||
|
||||
|
||||
var radius = Math.min(w, h) / 2; //change 2 to 1.4. It's hilarious.
|
||||
|
||||
var color = d3.scale.category20();
|
||||
|
||||
var arc = d3.svg.arc() //each datapoint will create one later.
|
||||
.outerRadius(radius - 20)
|
||||
.innerRadius(0);
|
||||
|
||||
var pie = d3.layout.pie()
|
||||
.sort(function (d) {
|
||||
return d.value;
|
||||
})
|
||||
.value(function (d) {
|
||||
return d.value;
|
||||
});
|
||||
|
||||
var svg = d3.select("#clusterGraphs").append("svg")
|
||||
.attr("width", w)
|
||||
.attr("height", h)
|
||||
.attr("class", "clusterChart")
|
||||
.append("g") //someone to transform. Groups data.
|
||||
.attr("transform", "translate(" + w / 2 + "," + h / 2 + ")");
|
||||
|
||||
var slices = svg.selectAll(".arc")
|
||||
.data(pie(dataset))
|
||||
.enter().append("g")
|
||||
.attr("class", "slice");
|
||||
|
||||
slices.append("path")
|
||||
.attr("d", arc)
|
||||
.style("fill", function (d, i) {
|
||||
return color(i);
|
||||
});
|
||||
|
||||
//add text, even
|
||||
slices.append("text")
|
||||
.attr("transform", function (d) {
|
||||
return "translate(" + arc.centroid(d) + ")";
|
||||
})
|
||||
.attr("class", "data-title")
|
||||
.text(function (d) {
|
||||
return d.data.key;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}());
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
//shared
|
||||
@import "shared";
|
||||
//cluster Charts
|
||||
@import "clusterCharts";
|
|
@ -188,7 +188,7 @@
|
|||
|
||||
"css/cluster.css": {
|
||||
"files": [
|
||||
|
||||
"frontend/scss/cluster.css"
|
||||
]
|
||||
},
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true, white: true, plusplus: true, regexp: true, nonpropdel: true */
|
||||
/*global require, module: true, STARTUP_PATH, DEV_APP_PATH, APP_PATH, MODULES_PATH,
|
||||
EXPORTS_SLOW_BUFFER */
|
||||
EXPORTS_SLOW_BUFFER, SYS_PLATFORM */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief JavaScript server functions
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, continue: true */
|
||||
/*global require, exports, ArangoClusterComm, ArangoClusterInfo */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -293,14 +293,7 @@ function byExample (data) {
|
|||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
idx = collection.lookupIndex(checks[k]);
|
||||
}
|
||||
catch (e) {
|
||||
// ignore any errors we counter during index lookup
|
||||
throw e;
|
||||
}
|
||||
|
||||
idx = collection.lookupIndex(checks[k]);
|
||||
if (idx !== null) {
|
||||
// found an index
|
||||
break;
|
||||
|
|
|
@ -2231,8 +2231,6 @@ function ahuacatlFunctionsTestSuite () {
|
|||
actual = getQueryResults("FOR x IN SKIPLIST(" + cn + ", { a: [[ '==', 1 ]], b: [[ '==', 2 ]] }) RETURN x");
|
||||
assertEqual(expected, actual);
|
||||
|
||||
assertQueryError(errors.ERROR_ARANGO_NO_INDEX.code, "RETURN SKIPLIST(" + cn + ", { b: [[ '==', 2 ]], a: [[ '==', 1 ]] })");
|
||||
|
||||
expected = [ ];
|
||||
actual = getQueryResults("FOR x IN SKIPLIST(" + cn + ", { a: [[ '==', 2 ]], b: [[ '==', 1 ]] }, 1, 1) RETURN x");
|
||||
assertEqual(expected, actual);
|
||||
|
|
Loading…
Reference in New Issue