veyron/{services/mgmt,tools}: end-to-end tests for binaryd, buildd, and profiled
This CL adds end-to-end 'test.sh' shell tests for the binary
repository, build server, and profile repository daemons. It also
makes minor modifications to these daemons and the client tools used
for communicatining with the daemons. Further, the CL extends an
existing end-to-end test for the application repository daemon with an
additional check.
This CL depends on https://veyron-review.googlesource.com/#/c/4005/
Change-Id: I4f02e552fc4ca776f2762058f1f936eb90c77fac
diff --git a/tools/application/impl/impl.go b/tools/application/impl/impl.go
index 6182b16..4a804f6 100644
--- a/tools/application/impl/impl.go
+++ b/tools/application/impl/impl.go
@@ -22,11 +22,11 @@
func getEnvelopeJSON(ctx context.T, app repository.Application, profiles string) ([]byte, error) {
env, err := app.Match(ctx, strings.Split(profiles, ","))
if err != nil {
- env = application.Envelope{}
+ return nil, err
}
j, err := json.MarshalIndent(env, "", " ")
if err != nil {
- return nil, fmt.Errorf("json: %v", err)
+ return nil, fmt.Errorf("MarshalIndent(%v) failed: %v", env, err)
}
return j, nil
}
@@ -34,7 +34,7 @@
func putEnvelopeJSON(ctx context.T, app repository.Application, profiles string, j []byte) error {
var env application.Envelope
if err := json.Unmarshal(j, &env); err != nil {
- return fmt.Errorf("json: %v", err)
+ return fmt.Errorf("Unmarshal(%v) failed: %v", string(j), err)
}
if err := app.Put(ctx, strings.Split(profiles, ","), env); err != nil {
return err
@@ -66,13 +66,14 @@
if expected, got := 2, len(args); expected != got {
return cmd.Errorf("match: incorrect number of arguments, expected %d, got %d", expected, got)
}
- app, err := repository.BindApplication(args[0])
+ name, profiles := args[0], args[1]
+ app, err := repository.BindApplication(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- j, err := getEnvelopeJSON(ctx, app, args[1])
+ j, err := getEnvelopeJSON(ctx, app, profiles)
if err != nil {
return err
}
@@ -96,17 +97,18 @@
if expected, got := 3, len(args); expected != got {
return cmd.Errorf("put: incorrect number of arguments, expected %d, got %d", expected, got)
}
- app, err := repository.BindApplication(args[0])
+ name, profiles, envelope := args[0], args[1], args[2]
+ app, err := repository.BindApplication(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
}
- j, err := ioutil.ReadFile(args[2])
+ j, err := ioutil.ReadFile(envelope)
if err != nil {
- return fmt.Errorf("read file %s: %v", args[2], err)
+ return fmt.Errorf("ReadFile(%v): %v", envelope, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- if err = putEnvelopeJSON(ctx, app, args[1], j); err != nil {
+ if err = putEnvelopeJSON(ctx, app, profiles, j); err != nil {
return err
}
fmt.Fprintln(cmd.Stdout(), "Application envelope added successfully.")
@@ -128,13 +130,14 @@
if expected, got := 2, len(args); expected != got {
return cmd.Errorf("remove: incorrect number of arguments, expected %d, got %d", expected, got)
}
- app, err := repository.BindApplication(args[0])
+ name, profile := args[0], args[1]
+ app, err := repository.BindApplication(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- if err = app.Remove(ctx, args[1]); err != nil {
+ if err = app.Remove(ctx, profile); err != nil {
return err
}
fmt.Fprintln(cmd.Stdout(), "Application envelope removed successfully.")
@@ -156,13 +159,14 @@
if expected, got := 2, len(args); expected != got {
return cmd.Errorf("edit: incorrect number of arguments, expected %d, got %d", expected, got)
}
- app, err := repository.BindApplication(args[0])
+ name, profile := args[0], args[1]
+ app, err := repository.BindApplication(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindApplication(%v) failed: %v", name, err)
}
f, err := ioutil.TempFile("", "application-edit-")
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("TempFile() failed: %v", err)
}
fileName := f.Name()
f.Close()
@@ -170,7 +174,7 @@
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
- envData, err := getEnvelopeJSON(ctx, app, args[1])
+ envData, err := getEnvelopeJSON(ctx, app, profile)
if err != nil {
return err
}
@@ -201,7 +205,7 @@
fmt.Fprintln(cmd.Stdout(), "Nothing changed")
return nil
}
- if err = putEnvelopeJSON(ctx, app, args[1], newData); err != nil {
+ if err = putEnvelopeJSON(ctx, app, profile, newData); err != nil {
fmt.Fprintf(cmd.Stdout(), "Error: %v\n", err)
if ans := promptUser(cmd, "Try again? [y/N] "); strings.ToUpper(ans) == "Y" {
continue
diff --git a/tools/build/impl/impl.go b/tools/build/impl/impl.go
index a584861..f575475 100644
--- a/tools/build/impl/impl.go
+++ b/tools/build/impl/impl.go
@@ -177,8 +177,8 @@
errchan <- fmt.Errorf("Advance() failed: %v", err)
return
}
- if _, err := stream.Finish(); err != nil {
- errchan <- fmt.Errorf("Finish() failed: %v", err)
+ if out, err := stream.Finish(); err != nil {
+ errchan <- fmt.Errorf("Finish() failed: (%v, %v)", out, err)
return
}
errchan <- nil
diff --git a/tools/profile/impl/impl.go b/tools/profile/impl/impl.go
index 8ca871e..41d19eb 100644
--- a/tools/profile/impl/impl.go
+++ b/tools/profile/impl/impl.go
@@ -25,9 +25,10 @@
if expected, got := 1, len(args); expected != got {
return cmd.Errorf("label: incorrect number of arguments, expected %d, got %d", expected, got)
}
- p, err := repository.BindProfile(args[0])
+ name := args[0]
+ p, err := repository.BindProfile(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
@@ -52,9 +53,10 @@
if expected, got := 1, len(args); expected != got {
return cmd.Errorf("description: incorrect number of arguments, expected %d, got %d", expected, got)
}
- p, err := repository.BindProfile(args[0])
+ name := args[0]
+ p, err := repository.BindProfile(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
@@ -66,8 +68,8 @@
return nil
}
-var cmdSpec = &cmdline.Command{
- Run: runSpec,
+var cmdSpecification = &cmdline.Command{
+ Run: runSpecification,
Name: "spec",
Short: "Shows the specification of the profile.",
Long: "Shows the specification of the profile.",
@@ -75,13 +77,14 @@
ArgsLong: "<profile> is the full name of the profile.",
}
-func runSpec(cmd *cmdline.Command, args []string) error {
+func runSpecification(cmd *cmdline.Command, args []string) error {
if expected, got := 1, len(args); expected != got {
return cmd.Errorf("spec: incorrect number of arguments, expected %d, got %d", expected, got)
}
- p, err := repository.BindProfile(args[0])
+ name := args[0]
+ p, err := repository.BindProfile(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
@@ -106,9 +109,10 @@
if expected, got := 1, len(args); expected != got {
return cmd.Errorf("put: incorrect number of arguments, expected %d, got %d", expected, got)
}
- p, err := repository.BindProfile(args[0])
+ name := args[0]
+ p, err := repository.BindProfile(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
}
// TODO(rthellend): Read an actual specification from a file.
@@ -125,7 +129,7 @@
if err := p.Put(ctx, spec); err != nil {
return err
}
- fmt.Fprintln(cmd.Stdout(), "Specification updated successfully.")
+ fmt.Fprintln(cmd.Stdout(), "Profile added successfully.")
return nil
}
@@ -142,9 +146,10 @@
if expected, got := 1, len(args); expected != got {
return cmd.Errorf("remove: incorrect number of arguments, expected %d, got %d", expected, got)
}
- p, err := repository.BindProfile(args[0])
+ name := args[0]
+ p, err := repository.BindProfile(name)
if err != nil {
- return fmt.Errorf("bind error: %v", err)
+ return fmt.Errorf("BindProfile(%v) failed: %v", name, err)
}
ctx, cancel := rt.R().NewContext().WithTimeout(time.Minute)
defer cancel()
@@ -160,6 +165,6 @@
Name: "profile",
Short: "Command-line tool for interacting with the veyron profile repository",
Long: "Command-line tool for interacting with the veyron profile repository",
- Children: []*cmdline.Command{cmdLabel, cmdDescription, cmdSpec, cmdPut, cmdRemove},
+ Children: []*cmdline.Command{cmdLabel, cmdDescription, cmdSpecification, cmdPut, cmdRemove},
}
}
diff --git a/tools/profile/impl/impl_test.go b/tools/profile/impl/impl_test.go
index 731e0a9..caf9248 100644
--- a/tools/profile/impl/impl_test.go
+++ b/tools/profile/impl/impl_test.go
@@ -153,7 +153,7 @@
if err := cmd.Execute([]string{"put", exists}); err != nil {
t.Fatalf("%v", err)
}
- if expected, got := "Specification updated successfully.", strings.TrimSpace(stdout.String()); got != expected {
+ if expected, got := "Profile added successfully.", strings.TrimSpace(stdout.String()); got != expected {
t.Errorf("Got %q, expected %q", got, expected)
}
stdout.Reset()