Update structure test yaml to schema 2.0.0. (#83)

* Update structure test yaml to schema 2.0.0.
diff --git a/WORKSPACE b/WORKSPACE
index 5240766..ced756f 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -23,9 +23,9 @@
 # https://docs.bazel.build/versions/master/be/workspace.html#git_repository
 http_archive(
     name = "io_bazel_rules_docker",
-    sha256 = "b0e6a7fb7a505de72c055ce4e9af4ef18417fe99f226af3afb6bfe3be7fe23ad",
-    strip_prefix = "rules_docker-993d320b7ad1376cbf5a1c5b7080d82a76e286a2",
-    urls = ["https://github.com/bazelbuild/rules_docker/archive/993d320b7ad1376cbf5a1c5b7080d82a76e286a2.tar.gz"],
+    sha256 = "5466861acd1e0a2afe745fdf383e5a4b5e06d19e571d49d252828cb2f2de13cb",
+    strip_prefix = "rules_docker-e325ffbf6508fe4cbaa3f5a0b09898f15e912d6a",
+    urls = ["https://github.com/bazelbuild/rules_docker/archive/e325ffbf6508fe4cbaa3f5a0b09898f15e912d6a.tar.gz"],
 )
 
 load(
diff --git a/container/common/clang.yaml b/container/common/clang.yaml
index 051f6cc..c4cabe9 100644
--- a/container/common/clang.yaml
+++ b/container/common/clang.yaml
@@ -1,12 +1,9 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 commandTests:
-- name: 'cc-envvar'
-  command: ['sh', '-c', 'echo $CC']
-  expectedOutput: ['/usr/local/bin/clang']
 - name: 'clang-version'
-  command: ['bash', '-c', 'clang --version']
+  command: 'clang'
+  args: ['--version']
   expectedOutput: ['clang version 7.0.0.*']
 
 fileExistenceTests:
@@ -74,3 +71,8 @@
   isDirectory: false
   path: '/usr/local/lib/clang/7.0.0/include/sanitizer/tsan_interface.h'
   shouldExist: true
+
+metadataTest:
+  env:
+    - key: 'CC'
+      value: '/usr/local/bin/clang'
diff --git a/container/common/go.yaml b/container/common/go.yaml
index 34806da..c9e4f01 100644
--- a/container/common/go.yaml
+++ b/container/common/go.yaml
@@ -1,12 +1,9 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 commandTests:
-- name: 'gopath-envvar'
-  command: ['sh', '-c', 'echo $GOPATH']
-  expectedOutput: ['/go']
 - name: 'go-version'
-  command: ['bash', '-c', 'go version']
+  command: 'go'
+  args: ['version']
   expectedOutput: ['go version go1.10 linux/amd64']
 
 fileExistenceTests:
@@ -14,3 +11,8 @@
   isDirectory: false
   path: '/usr/local/go/bin/go'
   shouldExist: true
+
+metadataTest:
+  env:
+    - key: 'GOPATH'
+      value: '/go'
diff --git a/container/common/java.yaml b/container/common/java.yaml
index bf2c8ff..0fe3ce6 100644
--- a/container/common/java.yaml
+++ b/container/common/java.yaml
@@ -1,16 +1,19 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 commandTests:
-- name: 'javahome-envvar'
-  command: ['sh', '-c', 'echo $JAVA_HOME']
-  expectedOutput: ['/usr/lib/jvm/java-8-openjdk-amd64']
 - name: 'java-version'
-  command: ['bash', '-c', 'java -version 2>&1']
-  expectedOutput: ['openjdk version \"1.8.*']
+  command: 'java'
+  args: ['-version']
+  # java outputs to stderr.
+  expectedError: ["openjdk version \"1.8.*"]
 
 fileExistenceTests:
 - name: 'OpenJDK'
   isDirectory: true
   path: '/usr/lib/jvm/java-8-openjdk-amd64'
   shouldExist: true
+
+metadataTest:
+  env:
+    - key: 'JAVA_HOME'
+      value: '/usr/lib/jvm/java-8-openjdk-amd64'
diff --git a/container/common/python2.yaml b/container/common/python2.yaml
index d0cbbfa..e7fe656 100644
--- a/container/common/python2.yaml
+++ b/container/common/python2.yaml
@@ -1,10 +1,11 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 commandTests:
 - name: 'python2-version'
-  command: ['bash', '-c', 'python -V 2>&1']
-  expectedOutput: ['Python 2.7.*']
+  command: 'python'
+  args: ['-V']
+  # python outputs to stderr.
+  expectedError: ['Python 2.7.*']
 
 fileExistenceTests:
 - name: 'Python2'
diff --git a/container/common/rbe-base.yaml b/container/common/rbe-base.yaml
index 91091c8..e91e278 100644
--- a/container/common/rbe-base.yaml
+++ b/container/common/rbe-base.yaml
@@ -1,36 +1,42 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 commandTests:
-- name: 'check-locale'
-  command: ['sh', '-c', 'echo $LC_ALL']
-  expectedOutput: ['C.UTF-8']
 - name: 'check-ed'
-  command: ['bash', '-c', 'ed --version']
+  command: 'ed'
+  args: ['--version']
   expectedOutput: ['GNU [eE]d .*']
 - name: 'check-file'
-  command: ['bash', '-c', 'file --version']
+  command: 'file'
+  args: ['--version']
   expectedOutput: ['file-.*']
 - name: 'check-git'
-  command: ['bash', '-c', 'git --version']
+  command: 'git'
+  args: ['--version']
   expectedOutput: ['git version .*']
 - name: 'check-less'
-  command: ['bash', '-c', 'less --version']
+  command: 'less'
+  args: ['--version']
   expectedOutput: ['less .*']
 - name: 'check-netcat'
-  command: ['bash', '-c', 'nc -h 2>&1']
-  expectedOutput: ['\[v.*']
+  command: 'nc'
+  args: ['-h']
+  # nc outputs to stderr.
+  expectedError: ['\[v.*']
 - name: 'check-openssl'
-  command: ['bash', '-c', 'openssl version']
+  command: 'openssl'
+  args: ['version']
   expectedOutput: ['OpenSSL .*']
 - name: 'check-patch'
-  command: ['bash', '-c', 'patch --version']
+  command: 'patch'
+  args: ['--version']
   expectedOutput: ['GNU patch .*']
 - name: 'check-wget'
-  command: ['bash', '-c', 'wget --version']
+  command: 'wget'
+  args: ['--version']
   expectedOutput: ['GNU Wget.* built on linux-gnu.*']
 - name: 'check-zip'
-  command: ['bash', '-c', 'zip --version']
+  command: 'zip'
+  args: ['--version']
   expectedOutput: ['.*This is Zip.*']
 
 fileExistenceTests:
@@ -38,3 +44,8 @@
   isDirectory: true
   path: '/'
   shouldExist: true
+
+metadataTest:
+  env:
+    - key: 'LC_ALL'
+      value: 'C.UTF-8'
diff --git a/container/debian8/builders/rbe-debian8/rbe-debian8.yaml b/container/debian8/builders/rbe-debian8/rbe-debian8.yaml
index 77c7238..e499def 100644
--- a/container/debian8/builders/rbe-debian8/rbe-debian8.yaml
+++ b/container/debian8/builders/rbe-debian8/rbe-debian8.yaml
@@ -1,5 +1,4 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 fileExistenceTests:
 - name: 'Python3'
@@ -7,16 +6,19 @@
   path: '/opt/python3.6/bin/python3'
   shouldExist: true
 
-# Common tests
 commandTests:
-- name: 'path-envvar'
-  command: ['sh', '-c', 'echo $PATH']
-  expectedOutput: ['/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python3.6/bin:/usr/local/go/bin']
 - name: 'python3-version'
-  command: ['bash', '-c', 'python3 -V']
+  command: 'python3'
+  args: ['-V']
   expectedOutput: ['Python 3.6.*']
 # This is failing in Debian9 base. Once resolved, move this test to
 # container/common/rbe-base.yaml.
 - name: 'check-curl'
-  command: ['bash', '-c', 'curl --version']
+  command: 'curl'
+  args: ['--version']
   expectedOutput: ['curl .* \(x86_64-pc-linux-gnu\).*']
+
+metadataTest:
+  env:
+    -key: 'PATH'
+     value: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python3.6/bin:/usr/local/go/bin'
diff --git a/container/debian8/debian8.yaml b/container/debian8/debian8.yaml
index 1a84140..219d20b 100644
--- a/container/debian8/debian8.yaml
+++ b/container/debian8/debian8.yaml
@@ -1,8 +1,7 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Distro-specific tests
-commandTests:
+fileContentTests:
 - name: 'os-version'
-  command: ['sh', '-c', 'cat /etc/issue.net']
-  expectedOutput: ['Debian GNU/Linux 8']
+  expectedContents: ['Debian GNU/Linux 8']
+  path: '/etc/issue.net'
diff --git a/container/experimental/rbe-debian9/rbe-debian9.yaml b/container/experimental/rbe-debian9/rbe-debian9.yaml
index ed66825..ed06f7d 100644
--- a/container/experimental/rbe-debian9/rbe-debian9.yaml
+++ b/container/experimental/rbe-debian9/rbe-debian9.yaml
@@ -1,22 +1,24 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Distro-specific tests
-commandTests:
+fileContentTests:
 - name: 'os-version'
-  command: ['sh', '-c', 'cat /etc/issue.net']
-  expectedOutput: ['Debian GNU/Linux 9']
+  expectedContents: ['Debian GNU/Linux 9']
+  path: '/etc/issue.net'
+
 fileExistenceTests:
 - name: 'Python3'
   isDirectory: false
   path: '/usr/bin/python3'
   shouldExist: true
 
-# Common tests
 commandTests:
-- name: 'path-envvar'
-  command: ['sh', '-c', 'echo $PATH']
-  expectedOutput: ['/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin']
 - name: 'python3-version'
-  command: ['bash', '-c', 'python3 -V']
+  command: 'python3'
+  args: ['-V']
   expectedOutput: ['Python 3.6.*']
+
+metadataTest:
+  env:
+    -key: 'PATH'
+     value: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin'
diff --git a/container/ubuntu16_04/builders/bazel/container.yaml b/container/ubuntu16_04/builders/bazel/container.yaml
index 6100f3c..791f95f 100644
--- a/container/ubuntu16_04/builders/bazel/container.yaml
+++ b/container/ubuntu16_04/builders/bazel/container.yaml
@@ -1,27 +1,26 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Common tests
 commandTests:
-- name: 'path-envvar'
-  command: ['sh', '-c', 'echo $PATH']
-  expectedOutput: ['/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin']
 - name: 'gcc-version'
-  command: ['bash', '-c', 'gcc --version 2>&1']
+  command: 'gcc'
+  args: ['--version']
   expectedOutput: ['gcc .*']
 - name: 'check-openssl'
-  command: ['bash', '-c', 'openssl version']
+  command: 'openssl'
+  args: ['version']
   expectedOutput: ['OpenSSL .*']
 - name: 'check-unzip'
-  command: ['bash', '-c', 'unzip']
+  command: 'unzip'
   expectedOutput: ['.*Usage: unzip .*']
 - name: 'check-zip'
-  command: ['bash', '-c', 'zip --version']
+  command: 'zip'
+  args: ['--version']
   expectedOutput: ['.*This is Zip.*']
 
 
-# TODO(xingao) Test entry point once rules_docker is updated with latest
-# version of the structure_test
-# https://github.com/bazelbuild/rules_docker/pull/416
-# metadataTest:
-#   entrypoint: ['bazel']
+metadataTest:
+  env:
+    - key: 'PATH'
+      value: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python3.6/bin'
+  entrypoint: ['bazel']
diff --git a/container/ubuntu16_04/builders/rbe-ubuntu16_04/rbe-ubuntu16_04.yaml b/container/ubuntu16_04/builders/rbe-ubuntu16_04/rbe-ubuntu16_04.yaml
index 77c7238..e222900 100644
--- a/container/ubuntu16_04/builders/rbe-ubuntu16_04/rbe-ubuntu16_04.yaml
+++ b/container/ubuntu16_04/builders/rbe-ubuntu16_04/rbe-ubuntu16_04.yaml
@@ -1,5 +1,4 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 fileExistenceTests:
 - name: 'Python3'
@@ -7,16 +6,19 @@
   path: '/opt/python3.6/bin/python3'
   shouldExist: true
 
-# Common tests
 commandTests:
-- name: 'path-envvar'
-  command: ['sh', '-c', 'echo $PATH']
-  expectedOutput: ['/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python3.6/bin:/usr/local/go/bin']
 - name: 'python3-version'
-  command: ['bash', '-c', 'python3 -V']
+  command: 'python3'
+  args: ['-V']
   expectedOutput: ['Python 3.6.*']
 # This is failing in Debian9 base. Once resolved, move this test to
 # container/common/rbe-base.yaml.
 - name: 'check-curl'
-  command: ['bash', '-c', 'curl --version']
+  command: 'curl'
+  args: ['--version']
   expectedOutput: ['curl .* \(x86_64-pc-linux-gnu\).*']
+
+metadataTest:
+  env:
+    - key: 'PATH'
+      value: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/python3.6/bin:/usr/local/go/bin'
diff --git a/container/ubuntu16_04/layers/bazel/bazel.yaml b/container/ubuntu16_04/layers/bazel/bazel.yaml
index a2e9f4d..267ab48 100644
--- a/container/ubuntu16_04/layers/bazel/bazel.yaml
+++ b/container/ubuntu16_04/layers/bazel/bazel.yaml
@@ -1,8 +1,7 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Common tests
 commandTests:
 - name: 'check-bazel'
-  command: ['bash', '-c', 'bazel']
+  command: 'bazel'
   expectedOutput: ['Usage: bazel <command> <options>.*']
diff --git a/container/ubuntu16_04/layers/docker-17.12.0/docker-17.12.0.yaml b/container/ubuntu16_04/layers/docker-17.12.0/docker-17.12.0.yaml
index 7756c84..4d93e6c 100644
--- a/container/ubuntu16_04/layers/docker-17.12.0/docker-17.12.0.yaml
+++ b/container/ubuntu16_04/layers/docker-17.12.0/docker-17.12.0.yaml
@@ -1,8 +1,8 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Common tests
 commandTests:
 - name: 'check-docker'
-  command: ['bash', '-c', 'docker --version']
+  command: 'docker'
+  args: ['--version']
   expectedOutput: ['Docker version 17.12.0.*']
diff --git a/container/ubuntu16_04/layers/git/git.yaml b/container/ubuntu16_04/layers/git/git.yaml
index 45ae1dd..e9b0a54 100644
--- a/container/ubuntu16_04/layers/git/git.yaml
+++ b/container/ubuntu16_04/layers/git/git.yaml
@@ -1,8 +1,8 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Common tests
 commandTests:
 - name: 'check-git'
-  command: ['bash', '-c', 'git --version']
+  command: 'git'
+  args: ['--version']
   expectedOutput: ['git version .*']
diff --git a/container/ubuntu16_04/ubuntu16_04.yaml b/container/ubuntu16_04/ubuntu16_04.yaml
index 880170e..caabcfe 100644
--- a/container/ubuntu16_04/ubuntu16_04.yaml
+++ b/container/ubuntu16_04/ubuntu16_04.yaml
@@ -1,8 +1,7 @@
-# TODO(xingao) Update to 2.0.0 to enable metadataTest.
-schemaVersion: "1.0.0"
+schemaVersion: "2.0.0"
 
 # Distro-specific tests
-commandTests:
+fileContentTests:
 - name: 'os-version'
-  command: ['sh', '-c', 'cat /etc/issue.net']
-  expectedOutput: ['Ubuntu 16.04.4 LTS']
+  expectedContents: ['Ubuntu 16.04.4 LTS']
+  path: '/etc/issue.net'