Browse code

Add notary binary requirement for tests

This PR adds the "notary" binary requirement for tests.

Previously, NotaryHosting was checking for the "notary-server"
binary under the name notaryBinary. This renames that reference to
notaryServerBinary, so that notaryBinary can rightly refer
to the actual "notary" binary.

Currently only one test actually uses the notary binary, so it's been
updated accordingly.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>

Christopher Jones authored on 2016/03/12 07:11:35
Showing 4 changed files
... ...
@@ -158,7 +158,7 @@ type DockerTrustSuite struct {
158 158
 }
159 159
 
160 160
 func (s *DockerTrustSuite) SetUpTest(c *check.C) {
161
-	testRequires(c, RegistryHosting, NotaryHosting)
161
+	testRequires(c, RegistryHosting, NotaryServerHosting)
162 162
 	s.reg = setupRegistry(c, false, false)
163 163
 	s.not = setupNotary(c)
164 164
 }
... ...
@@ -496,6 +496,7 @@ func (s *DockerTrustSuite) TestTrustedPushWithExpiredTimestamp(c *check.C) {
496 496
 }
497 497
 
498 498
 func (s *DockerTrustSuite) TestTrustedPushWithReleasesDelegation(c *check.C) {
499
+	testRequires(c, NotaryHosting)
499 500
 	repoName := fmt.Sprintf("%v/dockerclireleasedelegation/trusted", privateRegistryURL)
500 501
 	targetName := fmt.Sprintf("%s:latest", repoName)
501 502
 	pwd := "12345678"
... ...
@@ -97,6 +97,16 @@ var (
97 97
 		},
98 98
 		fmt.Sprintf("Test requires an environment that can host %s in the same host", notaryBinary),
99 99
 	}
100
+	NotaryServerHosting = testRequirement{
101
+		func() bool {
102
+			// for now notary-server binary is built only if we're running inside
103
+			// container through `make test`. Figure that out by testing if
104
+			// notary-server binary is in PATH.
105
+			_, err := exec.LookPath(notaryServerBinary)
106
+			return err == nil
107
+		},
108
+		fmt.Sprintf("Test requires an environment that can host %s in the same host", notaryServerBinary),
109
+	}
100 110
 	NotOverlay = testRequirement{
101 111
 		func() bool {
102 112
 			cmd := exec.Command("grep", "^overlay / overlay", "/proc/mounts")
... ...
@@ -19,8 +19,8 @@ import (
19 19
 	"github.com/go-check/check"
20 20
 )
21 21
 
22
-var notaryBinary = "notary-server"
23
-var notaryClientBinary = "notary"
22
+var notaryBinary = "notary"
23
+var notaryServerBinary = "notary-server"
24 24
 
25 25
 type testNotary struct {
26 26
 	cmd *exec.Cmd
... ...
@@ -91,7 +91,7 @@ func newTestNotary(c *check.C) (*testNotary, error) {
91 91
 	}
92 92
 
93 93
 	// run notary-server
94
-	cmd := exec.Command(notaryBinary, "-config", confPath)
94
+	cmd := exec.Command(notaryServerBinary, "-config", confPath)
95 95
 	if err := cmd.Start(); err != nil {
96 96
 		os.RemoveAll(tmp)
97 97
 		if os.IsNotExist(err) {
... ...
@@ -221,7 +221,7 @@ func notaryClientEnv(cmd *exec.Cmd, rootPwd, repositoryPwd string) {
221 221
 }
222 222
 
223 223
 func (s *DockerTrustSuite) setupDelegations(c *check.C, repoName, pwd string) {
224
-	initCmd := exec.Command(notaryClientBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "init", repoName)
224
+	initCmd := exec.Command(notaryBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "init", repoName)
225 225
 	notaryClientEnv(initCmd, pwd, pwd)
226 226
 	out, _, err := runCommandWithOutput(initCmd)
227 227
 	if err != nil {
... ...
@@ -243,7 +243,7 @@ func (s *DockerTrustSuite) setupDelegations(c *check.C, repoName, pwd string) {
243 243
 	}
244 244
 
245 245
 	// publishing first simulates the client pushing to a repo that they have been given delegated access to
246
-	pubCmd := exec.Command(notaryClientBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "publish", repoName)
246
+	pubCmd := exec.Command(notaryBinary, "-c", filepath.Join(s.not.dir, "client-config.json"), "publish", repoName)
247 247
 	notaryClientEnv(pubCmd, pwd, pwd)
248 248
 	out, _, err = runCommandWithOutput(pubCmd)
249 249
 	if err != nil {