mirror of https://gitee.com/bigwinds/arangodb
read-only: unit tests for client and server side
This commit is contained in:
parent
51d86d8351
commit
2405a5ffa2
|
@ -30,6 +30,7 @@ unittests-brief: \
|
|||
jslint \
|
||||
unittests-config \
|
||||
unittests-boost \
|
||||
unittests-shell-client-readonly\
|
||||
unittests-shell-server \
|
||||
unittests-shell-server-ahuacatl \
|
||||
unittests-http-server \
|
||||
|
@ -509,6 +510,37 @@ unittests-shell-server-ahuacatl:
|
|||
################################################################################
|
||||
### @brief SHELL CLIENT TESTS
|
||||
################################################################################
|
||||
UNITTESTS_READONLY = $(addprefix --javascript.unit-tests ,@top_srcdir@/js/client/tests/shell-changeMode.js)
|
||||
UNITTESTS_NO_READONLY = $(addprefix --javascript.unit-tests ,@top_srcdir@/js/client/tests/shell-noChangeMode.js)
|
||||
.PHONY: unittests-shell-client-readonly
|
||||
unittests-shell-client-readonly:
|
||||
$(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint unix://$(VOCDIR)/arango.sock --server.disable-authentication true" PROTO=unix
|
||||
@echo
|
||||
@echo "================================================================================"
|
||||
@echo "<< SHELL CLIENT READONLY >>"
|
||||
@echo "================================================================================"
|
||||
@echo
|
||||
|
||||
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock $(UNITTESTS_READONLY) || test "x$(FORCE)" == "x1"
|
||||
sleep 2
|
||||
kill `cat $(PIDFILE)`
|
||||
|
||||
while test -f $(PIDFILE); do sleep 1; done
|
||||
@if [ "$(VALGRIND)" != "" ]; then sleep 60; fi
|
||||
|
||||
@rm -rf "$(VOCDIR)"
|
||||
@echo
|
||||
|
||||
$(MAKE) start-server PID=$(PID) SERVER_START="--server.endpoint tcp://$(VOCHOST):$(VOCPORT) --server.disable-authentication true" PROTO=http
|
||||
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint tcp://$(VOCHOST):$(VOCPORT) $(UNITTESTS_NO_READONLY) || test "x$(FORCE)" == "x1"
|
||||
sleep 2
|
||||
kill `cat $(PIDFILE)`
|
||||
|
||||
while test -f $(PIDFILE); do sleep 1; done
|
||||
@if [ "$(VALGRIND)" != "" ]; then sleep 60; fi
|
||||
|
||||
@rm -rf "$(VOCDIR)"
|
||||
@echo
|
||||
|
||||
SHELL_CLIENT_ONLY = \
|
||||
@top_srcdir@/js/client/tests/shell-endpoints.js \
|
||||
|
@ -518,7 +550,6 @@ SHELL_CLIENT_ONLY = \
|
|||
SHELL_CLIENT = $(SHELL_COMMON) $(SHELL_CLIENT_ONLY)
|
||||
|
||||
.PHONY: unittests-shell-client
|
||||
|
||||
UNITTESTS_CLIENT = $(addprefix --javascript.unit-tests ,$(SHELL_CLIENT))
|
||||
|
||||
unittests-shell-client:
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*jslint indent: 2, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, nomen: true, sloppy: true */
|
||||
/*global require, assertEqual, assertNotEqual,
|
||||
print, print_plain, COMPARE_STRING, NORMALIZE_STRING,
|
||||
help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests for client-specific functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Esteban Lombeyda
|
||||
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var jsunity = require("jsunity");
|
||||
var db = require("org/arangodb").db;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function changeOperationModePositiveCaseTestSuite () {
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set up
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
setUp : function () {
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tear down
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
tearDown : function () {
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if the change of the operation mode of the arango server
|
||||
/// can be done.
|
||||
/// Note: this test needs an arango server with endpoint unix:...
|
||||
/// See target unittests-shell-client-readonly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testChangeMode : function () {
|
||||
var result =
|
||||
db._executeTransaction({collections: {},
|
||||
action: function () {
|
||||
var db = require('internal').db;
|
||||
var result = db._changeMode('ReadOnly');
|
||||
return result;
|
||||
}
|
||||
});
|
||||
assertTrue(result);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes the test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
jsunity.run(changeOperationModePositiveCaseTestSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
|
@ -0,0 +1,96 @@
|
|||
/*jslint indent: 2, maxlen: 120, vars: true, white: true, plusplus: true, nonpropdel: true, nomen: true, sloppy: true */
|
||||
/*global require, assertEqual, assertNotEqual,
|
||||
print, print_plain, COMPARE_STRING, NORMALIZE_STRING,
|
||||
help, start_pager, stop_pager, start_pretty_print, stop_pretty_print, start_color_print, stop_color_print */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests for client-specific functionality
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Esteban Lombeyda
|
||||
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var jsunity = require("jsunity");
|
||||
var arangodb = require("org/arangodb");
|
||||
var db = arangodb.db;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function changeOperationModeNegativeCaseTestSuite () {
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set up
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
setUp : function () {
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tear down
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
tearDown : function () {
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if the change of the operation mode of the arango server
|
||||
/// can be done.
|
||||
/// Note: this test needs an arango server with endpoint unix:...
|
||||
/// See target unittests-shell-client-readonly
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testTryChangeMode : function () {
|
||||
var modified = true;
|
||||
try {
|
||||
db._executeTransaction({collections: {},
|
||||
action: function () {
|
||||
var db = require('internal').db;
|
||||
var result = db._changeMode('ReadOnly');
|
||||
return result;
|
||||
}
|
||||
});} catch(e) {
|
||||
assertEqual(arangodb.errors.ERROR_FORBIDDEN.code, e.errorNum);
|
||||
modified = false;
|
||||
}
|
||||
assertFalse(modified);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief executes the test suite
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
jsunity.run(changeOperationModeNegativeCaseTestSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
|
@ -21,7 +21,7 @@
|
|||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Esteban Lombeyda
|
||||
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
Loading…
Reference in New Issue