diff --git a/js/client/modules/@arangodb/test-utils.js b/js/client/modules/@arangodb/test-utils.js index 4bff39c7fe..f252a1d1df 100755 --- a/js/client/modules/@arangodb/test-utils.js +++ b/js/client/modules/@arangodb/test-utils.js @@ -863,6 +863,8 @@ function runInRSpec (options, instanceInfo, file, addArgs) { ' c.ARANGO_PASSWORD = "' + options.password + '"\n' + ' c.add_setting :SKIP_TIMECRITICAL\n' + ' c.SKIP_TIMECRITICAL = ' + JSON.stringify(options.skipTimeCritical) + '\n' + + ' c.add_setting :STORAGE_ENGINE\n' + + ' c.STORAGE_ENGINE = ' + JSON.stringify(options.storageEngine) + '\n' + 'end\n'; fs.write(tmpname, rspecConfig); diff --git a/tests/rb/HttpInterface/api-index-geo-spec.rb b/tests/rb/HttpInterface/api-index-geo-spec.rb index f2f94af4ac..9ce45bf8e2 100644 --- a/tests/rb/HttpInterface/api-index-geo-spec.rb +++ b/tests/rb/HttpInterface/api-index-geo-spec.rb @@ -194,20 +194,25 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) - end + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + end cmd = api + "/#{iid}" doc = ArangoDB.get(cmd) diff --git a/tests/rb/HttpInterface/api-index-hash-spec.rb b/tests/rb/HttpInterface/api-index-hash-spec.rb index f43aeadb45..0baf72a101 100644 --- a/tests/rb/HttpInterface/api-index-hash-spec.rb +++ b/tests/rb/HttpInterface/api-index-hash-spec.rb @@ -6,9 +6,9 @@ require 'arangodb.rb' describe ArangoDB do prefix = "api-index-hash" -################################################################################ -## unique constraints during create -################################################################################ + ################################################################################ + ## unique constraints during create + ################################################################################ context "creating hash index:" do context "dealing with unique constraints violation:" do @@ -17,11 +17,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "does not create the index in case of violation" do # create a document cmd1 = "/_api/document?collection=#{@cn}" @@ -126,9 +126,9 @@ describe ArangoDB do end end -################################################################################ -## unique constraints during create -################################################################################ + ################################################################################ + ## unique constraints during create + ################################################################################ context "creating documents:" do context "dealing with unique constraints:" do @@ -137,11 +137,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "rolls back in case of violation, array index w/o deduplication" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"a[*]\" ], \"deduplicate\": false }" @@ -151,24 +151,24 @@ describe ArangoDB do doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) doc.parsed_response['deduplicate'].should eq(false) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : [ 1 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + body = "{ \"a\" : [ 2 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + body = "{ \"a\" : [ 3, 4 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + doc.code.should eq(201) # create a unique constraint violation @@ -177,7 +177,7 @@ describe ArangoDB do doc.code.should eq(409) end - + it "rolls back in case of violation, array index" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"a[*]\" ] }" @@ -187,24 +187,24 @@ describe ArangoDB do doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) doc.parsed_response['deduplicate'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : [ 1, 1 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + body = "{ \"a\" : [ 2 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + body = "{ \"a\" : [ 3, 4 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) doc.code.should eq(201) - + body = "{ \"a\" : [ 5, 5 ] }" doc = ArangoDB.log_post("#{prefix}-create2", cmd1, :body => body) @@ -216,7 +216,7 @@ describe ArangoDB do doc.code.should eq(409) end - + it "rolls back in case of violation" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"a\" ] }" @@ -225,7 +225,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -279,34 +279,39 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end it "rolls back in case of violation, sparse index" do @@ -317,7 +322,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -371,42 +376,47 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end end end -################################################################################ -## unique constraints during update -################################################################################ + ################################################################################ + ## unique constraints during update + ################################################################################ context "updating documents:" do context "dealing with unique constraints:" do @@ -415,11 +425,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "rolls back in case of violation" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"hash\", \"unique\" : true, \"fields\" : [ \"a\" ] }" @@ -428,7 +438,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -508,35 +518,40 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end it "rolls back in case of violation, sparse index" do @@ -547,7 +562,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("hash") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -627,35 +642,40 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end end diff --git a/tests/rb/HttpInterface/api-index-persistent-spec.rb b/tests/rb/HttpInterface/api-index-persistent-spec.rb index 6df9496968..cff22625a1 100644 --- a/tests/rb/HttpInterface/api-index-persistent-spec.rb +++ b/tests/rb/HttpInterface/api-index-persistent-spec.rb @@ -17,11 +17,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "does not create the index in case of violation" do # create a document cmd1 = "/_api/document?collection=#{@cn}" @@ -133,11 +133,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "rolls back in case of violation" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"persistent\", \"unique\" : true, \"fields\" : [ \"a\" ] }" @@ -146,7 +146,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("persistent") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -200,33 +200,38 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end it "rolls back in case of violation, sparse index" do @@ -237,7 +242,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("persistent") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -291,33 +296,38 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end end end @@ -333,11 +343,11 @@ describe ArangoDB do ArangoDB.drop_collection(@cn) @cid = ArangoDB.create_collection(@cn) end - + after do ArangoDB.drop_collection(@cn) end - + it "rolls back in case of violation" do cmd = "/_api/index?collection=#{@cn}" body = "{ \"type\" : \"persistent\", \"unique\" : true, \"fields\" : [ \"a\" ] }" @@ -346,7 +356,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("persistent") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -426,34 +436,39 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end it "rolls back in case of violation, sparse index" do @@ -464,7 +479,7 @@ describe ArangoDB do doc.code.should eq(201) doc.parsed_response['type'].should eq("persistent") doc.parsed_response['unique'].should eq(true) - + # create a document cmd1 = "/_api/document?collection=#{@cn}" body = "{ \"a\" : 1, \"b\" : 1 }" @@ -544,34 +559,39 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end end diff --git a/tests/rb/HttpInterface/api-index-skiplist-spec.rb b/tests/rb/HttpInterface/api-index-skiplist-spec.rb index ac8fa6b68b..834c3e088d 100644 --- a/tests/rb/HttpInterface/api-index-skiplist-spec.rb +++ b/tests/rb/HttpInterface/api-index-skiplist-spec.rb @@ -200,33 +200,38 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end it "rolls back in case of violation, sparse index" do @@ -291,33 +296,38 @@ describe ArangoDB do doc.parsed_response['_id'].should eq(id1) doc.parsed_response['_rev'].should eq(rev1) - # unload collection - cmd3 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd3) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd3 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd3) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd3) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd3 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd3) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd3 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd3) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd3) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check it again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) end - - # check it again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) end end end @@ -426,34 +436,39 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end it "rolls back in case of violation, sparse index" do @@ -544,34 +559,39 @@ describe ArangoDB do doc.parsed_response['_rev'].should eq(rev1) doc.parsed_response['_rev'].should_not eq(rev2) - # unload collection - cmd4 = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.log_put("#{prefix}", cmd4) - doc.code.should eq(200) - - # flush wal - doc = ArangoDB.put("/_admin/wal/flush"); - doc.code.should eq(200) - - cmd4 = "/_api/collection/#{@cn}" - doc = ArangoDB.log_get("#{prefix}", cmd4) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 - doc = ArangoDB.get(cmd4) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + # unload collection + cmd4 = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.log_put("#{prefix}", cmd4) doc.code.should eq(200) - sleep 1 + + # flush wal + doc = ArangoDB.put("/_admin/wal/flush"); + doc.code.should eq(200) + + cmd4 = "/_api/collection/#{@cn}" + doc = ArangoDB.log_get("#{prefix}", cmd4) + doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd4) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + # check the first document again + doc = ArangoDB.log_get("#{prefix}", cmd2) + + doc.code.should eq(200) + doc.parsed_response['a'].should eq(1) + doc.parsed_response['b'].should eq(1) + doc.parsed_response['_id'].should eq(id1) + doc.parsed_response['_rev'].should eq(rev1) + doc.parsed_response['_rev'].should_not eq(rev2) end - - # check the first document again - doc = ArangoDB.log_get("#{prefix}", cmd2) - - doc.code.should eq(200) - doc.parsed_response['a'].should eq(1) - doc.parsed_response['b'].should eq(1) - doc.parsed_response['_id'].should eq(id1) - doc.parsed_response['_rev'].should eq(rev1) - doc.parsed_response['_rev'].should_not eq(rev2) end end diff --git a/tests/rb/HttpInterface/api-index-spec.rb b/tests/rb/HttpInterface/api-index-spec.rb index 6905fe66ad..65720dc389 100644 --- a/tests/rb/HttpInterface/api-index-spec.rb +++ b/tests/rb/HttpInterface/api-index-spec.rb @@ -160,33 +160,39 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + + cmd = api + "/#{iid}" + doc = ArangoDB.get(cmd) + + doc.code.should eq(200) + doc.headers['content-type'].should eq("application/json; charset=utf-8") + doc.parsed_response['error'].should eq(false) + doc.parsed_response['code'].should eq(200) + doc.parsed_response['id'].should match(@reFull) + doc.parsed_response['id'].should eq(iid) + doc.parsed_response['type'].should eq("hash") + doc.parsed_response['unique'].should eq(true) + doc.parsed_response['sparse'].should eq(false) + doc.parsed_response['fields'].should eq([ "a", "b" ]) end - - cmd = api + "/#{iid}" - doc = ArangoDB.get(cmd) - - doc.code.should eq(200) - doc.headers['content-type'].should eq("application/json; charset=utf-8") - doc.parsed_response['error'].should eq(false) - doc.parsed_response['code'].should eq(200) - doc.parsed_response['id'].should match(@reFull) - doc.parsed_response['id'].should eq(iid) - doc.parsed_response['type'].should eq("hash") - doc.parsed_response['unique'].should eq(true) - doc.parsed_response['sparse'].should eq(false) - doc.parsed_response['fields'].should eq([ "a", "b" ]) end it "survives unload, sparse index" do @@ -202,18 +208,25 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... + end cmd = api + "/#{iid}" @@ -376,18 +389,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}" @@ -418,18 +437,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}" @@ -592,18 +617,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}" @@ -634,18 +665,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}" @@ -774,18 +811,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}" @@ -816,18 +859,24 @@ describe ArangoDB do iid = doc.parsed_response['id'] - cmd = "/_api/collection/#{@cn}/unload" - doc = ArangoDB.put(cmd) + if RSpec.configuration.STORAGE_ENGINE == "mmfiles" + cmd = "/_api/collection/#{@cn}/unload" + doc = ArangoDB.put(cmd) - doc.code.should eq(200) + doc.code.should eq(200) - cmd = "/_api/collection/#{@cn}" - doc = ArangoDB.get(cmd) - doc.code.should eq(200) - - while doc.parsed_response['status'] != 2 + cmd = "/_api/collection/#{@cn}" doc = ArangoDB.get(cmd) doc.code.should eq(200) + + i = 0 + while (doc.parsed_response['status'] != 2) && (i < 100) + doc = ArangoDB.get(cmd) + doc.code.should eq(200) + i += 1 + sleep 1 + end + expect(i).to be < 100 # Timeout... end cmd = api + "/#{iid}"