veyron/services/mgmt/application: creating a shell test
This CL adds a shell test for the application repository server
binary. Once approved, I will create similar tests for the other
application and node management components.
This CL depends on https://veyron-review.googlesource.com/#/c/3966/.
Change-Id: Ifd109339b168d2f6949e1a94d52832add070c53d
diff --git a/services/mgmt/application/applicationd/main.go b/services/mgmt/application/applicationd/main.go
index 34c9ac7..a152b6e 100644
--- a/services/mgmt/application/applicationd/main.go
+++ b/services/mgmt/application/applicationd/main.go
@@ -45,7 +45,7 @@
if err := server.Serve(*name, dispatcher); err != nil {
vlog.Fatalf("Serve(%v) failed: %v", *name, err)
}
- vlog.VI(0).Infof("Application manager published at %v/%v", endpoint, *name)
+ vlog.VI(0).Infof("Application repository published at %v/%v", endpoint, *name)
// Wait until shutdown.
<-signals.ShutdownOnSignals()
diff --git a/services/mgmt/application/applicationd/test.sh b/services/mgmt/application/applicationd/test.sh
new file mode 100755
index 0000000..cfa1004
--- /dev/null
+++ b/services/mgmt/application/applicationd/test.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Test the applicationd binary.
+#
+# This test starts an application repository server and uses the
+# application repository client to verify that <application>.Put(),
+# <application>.Match(), and <application>.Remove() work as expected.
+
+source "${VEYRON_ROOT}/environment/scripts/lib/shell_test.sh"
+
+build() {
+ local -r GO="${REPO_ROOT}/scripts/build/go"
+ "${GO}" build veyron/services/mgmt/application/applicationd || shell_test::fail "line ${LINENO}: failed to build 'applicationd'"
+ "${GO}" build veyron/services/mounttable/mounttabled || shell_test::fail "line ${LINENO}: failed to build 'mounttabled'"
+ "${GO}" build veyron/services/store/stored || shell_test::fail "line ${LINENO}: failed to build 'stored'"
+ "${GO}" build veyron/tools/application || shell_test::fail "line ${LINENO}: failed to build 'application'"
+ "${GO}" build veyron/tools/findunusedport || shell_test::fail "line ${LINENO}: failed to build 'findunusedport'"
+ "${GO}" build veyron/tools/identity || shell_test::fail "line ${LINENO}: failed to build 'identity'"
+}
+
+main() {
+ cd "${TMPDIR}"
+ build
+
+ # Generate a self-signed identity.
+ local -r ID_FILE=$(shell::tmp_file)
+ ./identity generate > "${ID_FILE}"
+
+ # Start the mounttable daemon.
+ local -r MT_PORT=$(./findunusedport)
+ local -r MT_LOG=$(shell::tmp_file)
+ ./mounttabled --address="127.0.0.1:${MT_PORT}" &> "${MT_LOG}" &
+ shell_test::wait_for "${MT_LOG}" "Mount table service"
+
+ export VEYRON_IDENTITY="${ID_FILE}"
+ export NAMESPACE_ROOT="/127.0.0.1:${MT_PORT}"
+
+ # Start the store daemon.
+ local -r DB_DIR=$(shell::tmp_dir)
+ local -r STORE="application-test-store"
+ local -r STORE_LOG=$(shell::tmp_file)
+ ./stored --name="${STORE}" --address=127.0.0.1:0 --db="${DB_DIR}" &> "${STORE_LOG}" &
+ shell_test::wait_for "${STORE_LOG}" "Viewer running"
+
+ # Start the application repository daemon.
+ local -r REPO="applicationd-test-repo"
+ local -r REPO_LOG=$(shell::tmp_file)
+ ./applicationd --name="${REPO}" --address=127.0.0.1:0 --store="${STORE}" &> "${REPO_LOG}" &
+ shell_test::wait_for "${REPO_LOG}" "Application repository published"
+
+ # Create an application envelope.
+ local -r APPLICATION="${REPO}/test-application/v1"
+ local -r PROFILE="test-profile"
+ local -r ENVELOPE=$(shell::tmp_file)
+ cat > "${ENVELOPE}" <<EOF
+{"Title":"title", "Args":[], "Binary":"foo", "Env":[]}
+EOF
+ ./application put "${APPLICATION}" "${PROFILE}" "${ENVELOPE}" || shell_test::fail "line ${LINENO}: 'put' failed"
+
+ # Match an application envelope.
+ local -r ENVELOPE2=$(shell::tmp_file)
+ ./application match "${APPLICATION}" "${PROFILE}" | tee "${ENVELOPE2}" || shell_test::fail "line ${LINENO}: 'match' failed"
+
+ # Remove an application envelope.
+ ./application remove "${APPLICATION}" "${PROFILE}" || shell_test::fail "line ${LINENO}: 'remove' failed"
+
+ shell_test::pass
+}
+
+main "$@"
diff --git a/tools/application/impl/impl.go b/tools/application/impl/impl.go
index ddaf5ac..6182b16 100644
--- a/tools/application/impl/impl.go
+++ b/tools/application/impl/impl.go
@@ -109,7 +109,7 @@
if err = putEnvelopeJSON(ctx, app, args[1], j); err != nil {
return err
}
- fmt.Fprintln(cmd.Stdout(), "Application updated successfully.")
+ fmt.Fprintln(cmd.Stdout(), "Application envelope added successfully.")
return nil
}