Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3503580
D4216.id14331.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D4216.id14331.diff
View Options
diff --git a/services/package.json b/services/package.json
--- a/services/package.json
+++ b/services/package.json
@@ -7,23 +7,17 @@
"build-all": "./scripts/build_base_image.sh && docker-compose build",
"build-base-image": "./scripts/build_base_image.sh",
"run-tunnelbroker-service": "./scripts/run_server_image.sh tunnelbroker",
- "test-tunnelbroker-service": "./scripts/test_service.sh tunnelbroker",
"run-tunnelbroker-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/run_server_image.sh tunnelbroker",
- "test-tunnelbroker-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/test_service.sh tunnelbroker",
"build-backup-base": "./scripts/build_base_image.sh && docker-compose build backup-base",
"run-backup-service": "./scripts/run_server_image.sh backup",
- "test-backup-service": "./scripts/test_service.sh backup",
"run-backup-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/run_server_image.sh backup",
- "test-backup-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/test_service.sh backup",
"build-blob-base": "./scripts/build_base_image.sh && docker-compose build blob-base",
"run-blob-service": "./scripts/run_server_image.sh blob",
- "test-blob-service": "./scripts/test_service.sh blob",
"run-blob-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/run_server_image.sh blob",
- "test-blob-service-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/test_service.sh blob",
"run-all-services": "./scripts/run_all_services.sh",
- "test-all-services": "./scripts/test_all_services.sh",
- "test-all-services-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/test_all_services.sh",
+ "run-unit-tests": "./scripts/run_unit_tests.sh",
+ "run-integration-tests": "./scripts/run_integration_tests.sh",
"run-all-services-in-sandbox": "COMM_SERVICES_SANDBOX=1 ./scripts/run_all_services.sh",
"init-local-cloud": "./scripts/init_local_cloud.sh"
}
-}
\ No newline at end of file
+}
diff --git a/services/scripts/list_services.sh b/services/scripts/list_services.sh
--- a/services/scripts/list_services.sh
+++ b/services/scripts/list_services.sh
@@ -2,4 +2,5 @@
set -e
-ls | grep -vE 'base-image|docker.compose.yml|package.json|scripts'
+find . -maxdepth 1 ! -name "base-image" ! -name "docker-compose.yml" ! -name "package.json" ! -name "scripts" ! -name "node_modules" ! -name "commtest" ! -name "lib" ! -name "terraform" ! -name ".*" -execdir echo {} ';'
+
diff --git a/services/scripts/run_integration_tests.sh b/services/scripts/run_integration_tests.sh
new file mode 100755
--- /dev/null
+++ b/services/scripts/run_integration_tests.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+set -e
+
+export COMM_TEST_SERVICES=1
+export COMM_SERVICES_DEV_MODE=1
+
+SERVICES=$(./scripts/list_services.sh)
+
+run_integration_test () {
+ echo "integration tests tests will be run for the $1 service"
+ # add -- --nocapture in the end to enable logs
+ cargo test "$1"_test --test '*' --manifest-path=commtest/Cargo.toml #-- --nocapture
+}
+
+list_expected () {
+ echo "Expected one of these:";
+ echo "$SERVICES";
+ echo "all";
+}
+
+if [[ -z "$1" ]]; then
+ echo "No service specified";
+ list_expected;
+ exit 1;
+fi
+
+if [[ "$1" == "all" ]]; then
+ for SERVICE in "$SERVICES"; do
+ run_integration_test "$SERVICE"
+ done
+ exit 0;
+fi;
+
+SERVICE=$(grep "$1" <<< "$SERVICES")
+
+if [[ "$SERVICE" != "$1" ]]; then
+ echo "No such service: $1";
+ list_expected;
+ exit 1;
+fi;
+
+run_integration_test "$SERVICE"
diff --git a/services/scripts/run_unit_tests.sh b/services/scripts/run_unit_tests.sh
new file mode 100755
--- /dev/null
+++ b/services/scripts/run_unit_tests.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+set -e
+
+export COMM_TEST_SERVICES=1
+export COMM_SERVICES_DEV_MODE=1
+
+SERVICES=$(./scripts/list_services.sh)
+
+run_unit_test () {
+ echo "unit tests will be run for the $1 service"
+
+ docker-compose build "$1"-server
+ docker-compose run "$1"-server
+}
+
+list_expected () {
+ echo "Expected one of these:";
+ echo "$SERVICES";
+}
+
+if [[ -z "$1" ]]; then
+ echo "No service specified";
+ list_expected;
+ exit 1;
+fi
+
+if [[ "$1" == "all" ]]; then
+ for SERVICE in $SERVICES; do
+ run_unit_test "$SERVICE"
+ done
+ exit 0;
+fi;
+
+SERVICE=$(grep "$1" <<< "$SERVICES")
+
+if [[ "$SERVICE" != "$1" ]]; then
+ echo "No such service: $1";
+ list_expected;
+ exit 1;
+fi;
+
+run_unit_test "$SERVICE"
diff --git a/services/scripts/test_all_services.sh b/services/scripts/test_all_services.sh
deleted file mode 100755
--- a/services/scripts/test_all_services.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-SERVICES=$(./scripts/list_services.sh)
-
-for SERVICE in $SERVICES; do
- ./scripts/test_service.sh "$SERVICE"
-done
diff --git a/services/scripts/test_service.sh b/services/scripts/test_service.sh
deleted file mode 100755
--- a/services/scripts/test_service.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-SERVICES=$(./scripts/list_services.sh)
-SERVICE=$(grep "$1" <<< echo "$SERVICES") || echo "No such service: $1"
-
-if [[ "$SERVICE" != "$1" ]]; then
- echo "Expected one of these:"
- echo "$SERVICES"
- exit 1;
-fi;
-
-export COMM_TEST_SERVICES=1
-
-echo "${SERVICE} service will be tested"
-
-docker-compose build "${SERVICE}"-server
-docker-compose run "${SERVICE}"-server
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 5:41 AM (13 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683730
Default Alt Text
D4216.id14331.diff (5 KB)
Attached To
Mode
D4216: [services] Tests - Fix scripts
Attached
Detach File
Event Timeline
Log In to Comment