summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/installers/head.sh2
-rw-r--r--tools/vm/BUILD (renamed from tools/images/BUILD)16
-rw-r--r--tools/vm/README.md (renamed from tools/images/README.md)2
-rwxr-xr-xtools/vm/build.sh (renamed from tools/images/build.sh)8
-rw-r--r--tools/vm/defs.bzl (renamed from tools/images/defs.bzl)33
-rwxr-xr-xtools/vm/execute.sh (renamed from tools/images/execute.sh)10
-rw-r--r--tools/vm/test.cc (renamed from tools/images/test.cc)8
-rwxr-xr-xtools/vm/ubuntu1604/10_core.sh (renamed from tools/images/ubuntu1604/10_core.sh)0
-rwxr-xr-xtools/vm/ubuntu1604/20_bazel.sh (renamed from tools/images/ubuntu1604/20_bazel.sh)0
-rwxr-xr-xtools/vm/ubuntu1604/25_docker.sh (renamed from tools/images/ubuntu1604/25_docker.sh)0
-rwxr-xr-xtools/vm/ubuntu1604/30_containerd.sh (renamed from tools/images/ubuntu1604/30_containerd.sh)0
-rwxr-xr-xtools/vm/ubuntu1604/40_kokoro.sh (renamed from tools/images/ubuntu1604/40_kokoro.sh)0
-rw-r--r--tools/vm/ubuntu1604/BUILD (renamed from tools/images/ubuntu1604/BUILD)0
-rw-r--r--tools/vm/ubuntu1804/BUILD (renamed from tools/images/ubuntu1804/BUILD)2
-rwxr-xr-xtools/vm/zone.sh (renamed from tools/images/zone.sh)0
15 files changed, 49 insertions, 32 deletions
diff --git a/tools/installers/head.sh b/tools/installers/head.sh
index 9de8f138c..7fc566ebd 100755
--- a/tools/installers/head.sh
+++ b/tools/installers/head.sh
@@ -15,7 +15,7 @@
# limitations under the License.
# Install our runtime.
-$(dirname $0)/runsc install
+$(find . -executable -type f -name runsc) install
# Restart docker.
service docker restart || true
diff --git a/tools/images/BUILD b/tools/vm/BUILD
index 8d319e3e4..f7160c627 100644
--- a/tools/images/BUILD
+++ b/tools/vm/BUILD
@@ -1,5 +1,5 @@
load("//tools:defs.bzl", "cc_binary", "gtest")
-load("//tools/images:defs.bzl", "vm_image", "vm_test")
+load("//tools/vm:defs.bzl", "vm_image", "vm_test")
package(
default_visibility = ["//:sandbox"],
@@ -37,27 +37,21 @@ vm_image(
family = "ubuntu-1604-lts",
project = "ubuntu-os-cloud",
scripts = [
- "//tools/images/ubuntu1604",
+ "//tools/vm/ubuntu1604",
],
)
-vm_test(
- name = "ubuntu1604_test",
- image = ":ubuntu1604",
- targets = [":test"],
-)
-
vm_image(
name = "ubuntu1804",
family = "ubuntu-1804-lts",
project = "ubuntu-os-cloud",
scripts = [
- "//tools/images/ubuntu1804",
+ "//tools/vm/ubuntu1804",
],
)
vm_test(
- name = "ubuntu1804_test",
- image = ":ubuntu1804",
+ name = "vm_test",
+ shard_count = 2,
targets = [":test"],
)
diff --git a/tools/images/README.md b/tools/vm/README.md
index 26c0f84f2..898c95fca 100644
--- a/tools/images/README.md
+++ b/tools/vm/README.md
@@ -1,4 +1,4 @@
-# Images
+# VM Images & Tests
All commands in this directory require the `gcloud` project to be set.
diff --git a/tools/images/build.sh b/tools/vm/build.sh
index f39f723b8..5d3dc0bbf 100755
--- a/tools/images/build.sh
+++ b/tools/vm/build.sh
@@ -43,6 +43,9 @@ if ! [[ -z "${existing}" ]]; then
exit 0
fi
+# Standard arguments (applies only on script execution).
+declare -ar SSH_ARGS=("-o" "ConnectTimeout=60" "--")
+
# gcloud has path errors; is this a result of being a genrule?
export PATH=${PATH:-/bin:/usr/bin:/usr/local/bin}
@@ -69,9 +72,9 @@ declare -r start=$(date +%s)
declare -r end=$((${start}+${timeout}))
while [[ "$(date +%s)" -lt "${end}" ]] && [[ "${success}" -lt 3 ]]; do
echo -n "."
- if gcloud compute ssh --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- env - true 2>/dev/null; then
+ if gcloud compute ssh --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- true 2>/dev/null; then
success=$((${success}+1))
- elif gcloud compute ssh --internal-ip --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- env - true 2>/dev/null; then
+ elif gcloud compute ssh --internal-ip --zone "${ZONE}" "${USERNAME}"@"${INSTANCE_NAME}" -- true 2>/dev/null; then
success=$((${success}+1))
internal="--internal-ip"
fi
@@ -89,6 +92,7 @@ for arg; do
(set -x; gcloud compute ssh ${internal} \
--zone "${ZONE}" \
"${USERNAME}"@"${INSTANCE_NAME}" -- \
+ "${SSH_ARGS[@]}" \
sudo bash - <"${arg}" >/dev/null)
done
diff --git a/tools/images/defs.bzl b/tools/vm/defs.bzl
index 2847e1847..24bf0aabc 100644
--- a/tools/images/defs.bzl
+++ b/tools/vm/defs.bzl
@@ -38,13 +38,13 @@ vm_image_builder = rule(
attrs = {
"_builder": attr.label(
executable = True,
- default = "//tools/images:builder",
+ default = "//tools/vm:builder",
cfg = "host",
),
"username": attr.string(default = "$(whoami)"),
"zone": attr.label(
executable = True,
- default = "//tools/images:zone",
+ default = "//tools/vm:zone",
cfg = "host",
),
"family": attr.string(mandatory = True),
@@ -80,14 +80,14 @@ def _vm_image_impl(ctx):
# resolved and consumed in the generation of the trivial echo script.
return [DefaultInfo(executable = echo)]
-_vm_image = rule(
+_vm_image_test = rule(
attrs = {
"builder": attr.label(
executable = True,
cfg = "host",
),
},
- executable = True,
+ test = True,
implementation = _vm_image_impl,
)
@@ -96,9 +96,13 @@ def vm_image(name, **kwargs):
name = name + "_builder",
**kwargs
)
- _vm_image(
+ _vm_image_test(
name = name,
builder = ":" + name + "_builder",
+ tags = [
+ "local",
+ "manual",
+ ],
)
def _vm_test_impl(ctx):
@@ -109,9 +113,9 @@ def _vm_test_impl(ctx):
# they can be copied over for remote execution.
runner_content = "\n".join([
"#!/bin/bash",
- "export ZONE=$(cat %s)" % ctx.files.zone[0].short_path,
+ "export ZONE=$(%s)" % ctx.files.zone[0].short_path,
"export USERNAME=%s" % ctx.attr.username,
- "export IMAGE=$(cat %s)" % ctx.files.image[0].short_path,
+ "export IMAGE=$(%s)" % ctx.files.image[0].short_path,
"export SUDO=%s" % "true" if ctx.attr.sudo else "false",
"%s %s" % (
ctx.executable.executer.short_path,
@@ -141,17 +145,19 @@ def _vm_test_impl(ctx):
_vm_test = rule(
attrs = {
"image": attr.label(
- mandatory = True,
+ executable = True,
+ default = "//tools/vm:ubuntu1804",
cfg = "host",
),
"executer": attr.label(
executable = True,
- default = "//tools/images:executer",
+ default = "//tools/vm:executer",
cfg = "host",
),
"username": attr.string(default = "$(whoami)"),
"zone": attr.label(
- default = "//tools/images:zone",
+ executable = True,
+ default = "//tools/vm:zone",
cfg = "host",
),
"sudo": attr.bool(default = True),
@@ -167,7 +173,7 @@ _vm_test = rule(
)
def vm_test(
- installer = "//tools/installers:head",
+ installers = None,
**kwargs):
"""Runs the given targets as a remote test.
@@ -176,8 +182,9 @@ def vm_test(
**kwargs: All test arguments. Should include targets and image.
"""
targets = kwargs.pop("targets", [])
- if installer:
- targets = [installer] + targets
+ if installers == None:
+ installers = ["//tools/installers:head"]
+ targets = installers + targets
if default_installer():
targets = [default_installer()] + targets
_vm_test(
diff --git a/tools/images/execute.sh b/tools/vm/execute.sh
index ba4b1ac0e..1f1f3ce01 100755
--- a/tools/images/execute.sh
+++ b/tools/vm/execute.sh
@@ -31,6 +31,9 @@ declare -r MACHINE=${MACHINE:-n1-standard-1}
declare -r ZONE=${ZONE:-us-central1-f}
declare -r SUDO=${SUDO:-false}
+# Standard arguments (applies only on script execution).
+declare -ar SSH_ARGS=("-o" "ConnectTimeout=60" "--")
+
# This script is executed as a test rule, which will reset the value of HOME.
# Unfortunately, it is needed to load the gconfig credentials. We will reset
# HOME when we actually execute in the remote environment, defined below.
@@ -81,7 +84,9 @@ tar czf - --dereference --exclude=.git . |
gcloud compute ssh \
--ssh-key-file="${KEYNAME}" \
--zone "${ZONE}" \
- "${USERNAME}"@"${INSTANCE_NAME}" -- tar xzf -
+ "${USERNAME}"@"${INSTANCE_NAME}" -- \
+ "${SSH_ARGS[@]}" \
+ tar xzf -
# Execute the command remotely.
for cmd; do
@@ -108,6 +113,7 @@ for cmd; do
--ssh-key-file="${KEYNAME}" \
--zone "${ZONE}" \
"${USERNAME}"@"${INSTANCE_NAME}" -- \
+ "${SSH_ARGS[@]}" \
mkdir -p "/tmp/${REMOTE_TMPDIR}"
fi
if [[ -v XML_OUTPUT_FILE ]]; then
@@ -123,6 +129,7 @@ for cmd; do
--ssh-key-file="${KEYNAME}" \
--zone "${ZONE}" \
"${USERNAME}"@"${INSTANCE_NAME}" -- \
+ "${SSH_ARGS[@]}" \
"${PREFIX[@]}" "${cmd}"
# Collect relevant results.
@@ -147,6 +154,7 @@ for cmd; do
--ssh-key-file="${KEYNAME}" \
--zone "${ZONE}" \
"${USERNAME}"@"${INSTANCE_NAME}" -- \
+ "${SSH_ARGS[@]}" \
rm -rf "/tmp/${REMOTE_TMPDIR}"
fi
done
diff --git a/tools/images/test.cc b/tools/vm/test.cc
index 4f31d93c5..c0ceacda1 100644
--- a/tools/images/test.cc
+++ b/tools/vm/test.cc
@@ -16,8 +16,12 @@
namespace {
-TEST(Image, Sanity) {
- // Do nothing.
+TEST(Image, Sanity0) {
+ // Do nothing (in shard 0).
+}
+
+TEST(Image, Sanity1) {
+ // Do nothing (in shard 1).
}
} // namespace
diff --git a/tools/images/ubuntu1604/10_core.sh b/tools/vm/ubuntu1604/10_core.sh
index cd518d6ac..cd518d6ac 100755
--- a/tools/images/ubuntu1604/10_core.sh
+++ b/tools/vm/ubuntu1604/10_core.sh
diff --git a/tools/images/ubuntu1604/20_bazel.sh b/tools/vm/ubuntu1604/20_bazel.sh
index bb7afa676..bb7afa676 100755
--- a/tools/images/ubuntu1604/20_bazel.sh
+++ b/tools/vm/ubuntu1604/20_bazel.sh
diff --git a/tools/images/ubuntu1604/25_docker.sh b/tools/vm/ubuntu1604/25_docker.sh
index 11eea2d72..11eea2d72 100755
--- a/tools/images/ubuntu1604/25_docker.sh
+++ b/tools/vm/ubuntu1604/25_docker.sh
diff --git a/tools/images/ubuntu1604/30_containerd.sh b/tools/vm/ubuntu1604/30_containerd.sh
index fb3699c12..fb3699c12 100755
--- a/tools/images/ubuntu1604/30_containerd.sh
+++ b/tools/vm/ubuntu1604/30_containerd.sh
diff --git a/tools/images/ubuntu1604/40_kokoro.sh b/tools/vm/ubuntu1604/40_kokoro.sh
index 06a1e6c48..06a1e6c48 100755
--- a/tools/images/ubuntu1604/40_kokoro.sh
+++ b/tools/vm/ubuntu1604/40_kokoro.sh
diff --git a/tools/images/ubuntu1604/BUILD b/tools/vm/ubuntu1604/BUILD
index ab1df0c4c..ab1df0c4c 100644
--- a/tools/images/ubuntu1604/BUILD
+++ b/tools/vm/ubuntu1604/BUILD
diff --git a/tools/images/ubuntu1804/BUILD b/tools/vm/ubuntu1804/BUILD
index 7aa1ecdf7..0c8856dde 100644
--- a/tools/images/ubuntu1804/BUILD
+++ b/tools/vm/ubuntu1804/BUILD
@@ -2,6 +2,6 @@ package(licenses = ["notice"])
alias(
name = "ubuntu1804",
- actual = "//tools/images/ubuntu1604",
+ actual = "//tools/vm/ubuntu1604",
visibility = ["//:sandbox"],
)
diff --git a/tools/images/zone.sh b/tools/vm/zone.sh
index 79569fb19..79569fb19 100755
--- a/tools/images/zone.sh
+++ b/tools/vm/zone.sh