Merge "services/device/device: updateall: kill instance only if running; recover if err"
diff --git a/examples/hello/hello_test.go b/examples/hello/hello_test.go
index bfeeecb..731de44 100644
--- a/examples/hello/hello_test.go
+++ b/examples/hello/hello_test.go
@@ -6,10 +6,14 @@
 
 import (
 	"fmt"
+	"os"
+	"strings"
+	"time"
 
 	"v.io/x/ref/envvar"
 	"v.io/x/ref/lib/security"
 	_ "v.io/x/ref/profiles"
+	"v.io/x/ref/test/modules"
 	"v.io/x/ref/test/testutil"
 	"v.io/x/ref/test/v23tests"
 )
@@ -18,6 +22,25 @@
 
 func init() {
 	envvar.ClearCredentials()
+	// Unset all the namespace variables too.
+	for _, ev := range os.Environ() {
+		p := strings.SplitN(ev, "=", 2)
+		if len(p) != 2 {
+			continue
+		}
+		key := p[0]
+		if strings.HasPrefix(key, envvar.NamespacePrefix) {
+			os.Unsetenv(key)
+		}
+	}
+}
+
+var opts = modules.StartOpts{
+	StartTimeout:    20 * time.Second,
+	ShutdownTimeout: 20 * time.Second,
+	ExpectTimeout:   20 * time.Second,
+	ExecProtocol:    false,
+	External:        true,
 }
 
 // setupCredentials makes a bunch of credentials directories.
@@ -50,9 +73,10 @@
 	}
 	clientbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloclient")
 	serverbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloserver")
-	server := serverbin.WithEnv(creds["helloserver"]).Start()
+	server := serverbin.WithStartOpts(opts).WithEnv(creds["helloserver"]).Start()
 	name := server.ExpectVar("SERVER_NAME")
-	clientbin.WithEnv(creds["helloclient"]).Run("--name", name)
+
+	clientbin.WithEnv(creds["helloclient"]).WithStartOpts(opts).Run("--name", name)
 }
 
 func V23TestHelloAgentd(i *v23tests.T) {
@@ -60,7 +84,7 @@
 	if err != nil {
 		i.Fatalf("Could not create credentials: %v", err)
 	}
-	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd")
+	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd").WithStartOpts(opts)
 	serverbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloserver")
 	clientbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloclient")
 	server := agentdbin.WithEnv(creds["helloserver"]).Start(serverbin.Path())
@@ -73,16 +97,19 @@
 	if err != nil {
 		i.Fatalf("Could not create credentials: %v", err)
 	}
-	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd")
+	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd").WithStartOpts(opts)
 	mounttabledbin := i.BuildGoPkg("v.io/x/ref/services/mounttable/mounttabled")
 	serverbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloserver")
 	clientbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloclient")
 	name := "hello"
 	mounttabled := agentdbin.WithEnv(creds["mounttabled"]).Start(mounttabledbin.Path(),
 		"--v23.tcp.address", "127.0.0.1:0")
-	mt := fmt.Sprintf("%s=%s", envvar.NamespacePrefix, mounttabled.ExpectVar("NAME"))
-	agentdbin.WithEnv(creds["helloserver"], mt).Start(serverbin.Path(), "--name", name)
-	agentdbin.WithEnv(creds["helloclient"], mt).Run(clientbin.Path(), "--name", name)
+	mtname := mounttabled.ExpectVar("NAME")
+	mt := fmt.Sprintf("%s=%s", envvar.NamespacePrefix, mtname)
+	agentdbin.WithEnv(creds["helloserver"], mt).Start(serverbin.Path(), "--name", name,
+		"--v23.namespace.root", mtname)
+	agentdbin.WithEnv(creds["helloclient"], mt).Run(clientbin.Path(), "--name", name,
+		"--v23.namespace.root", mtname)
 }
 
 func V23TestHelloProxy(i *v23tests.T) {
@@ -95,7 +122,7 @@
 	if err != nil {
 		i.Fatalf("Could not create credentials: %v", err)
 	}
-	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd")
+	agentdbin := i.BuildGoPkg("v.io/x/ref/services/agent/agentd").WithStartOpts(opts)
 	mounttabledbin := i.BuildGoPkg("v.io/x/ref/services/mounttable/mounttabled")
 	proxydbin := i.BuildGoPkg("v.io/x/ref/services/proxy/proxyd")
 	serverbin := i.BuildGoPkg("v.io/x/ref/examples/hello/helloserver")
@@ -104,15 +131,19 @@
 	name := "hello"
 	mounttabled := agentdbin.WithEnv(creds["mounttabled"]).Start(mounttabledbin.Path(),
 		"--v23.tcp.address", "127.0.0.1:0")
-	mt := fmt.Sprintf("%s=%s", envvar.NamespacePrefix, mounttabled.ExpectVar("NAME"))
+	mtname := mounttabled.ExpectVar("NAME")
+	mt := fmt.Sprintf("%s=%s", envvar.NamespacePrefix, mtname)
 	agentdbin.WithEnv(creds["proxyd"], mt).Start(proxydbin.Path(),
 		"--name", proxyname, "--v23.tcp.address", "127.0.0.1:0",
+		"--v23.namespace.root", mtname,
 		"--access-list", "{\"In\":[\"root\"]}")
 	server := agentdbin.WithEnv(creds["helloserver"], mt).Start(serverbin.Path(),
-		"--name", name, "--v23.proxy", proxyname, "--v23.tcp.address", "")
+		"--name", name, "--v23.proxy", proxyname, "--v23.tcp.address", "",
+		"--v23.namespace.root", mtname)
 	// Prove that we're listening on a proxy.
 	if sn := server.ExpectVar("SERVER_NAME"); sn != "proxy" {
 		i.Fatalf("helloserver not listening through proxy: %s.", sn)
 	}
-	agentdbin.WithEnv(creds["helloclient"], mt).Run(clientbin.Path(), "--name", name)
+	agentdbin.WithEnv(creds["helloclient"], mt).Run(clientbin.Path(), "--name", name,
+		"--v23.namespace.root", mtname)
 }
diff --git a/lib/vdl/codegen/java/file_array.go b/lib/vdl/codegen/java/file_array.go
index e0ef7ab..0501a75 100644
--- a/lib/vdl/codegen/java/file_array.go
+++ b/lib/vdl/codegen/java/file_array.go
@@ -24,7 +24,7 @@
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
 @io.v.v23.vdl.ArrayLength({{.Length}})
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.VdlArray<{{.ElemType}}> {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.VdlArray<{{.ElemType}}> {
     private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_complex.go b/lib/vdl/codegen/java/file_complex.go
index 7d4e382..1f4fffc 100644
--- a/lib/vdl/codegen/java/file_complex.go
+++ b/lib/vdl/codegen/java/file_complex.go
@@ -22,7 +22,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends {{.VdlComplex}} {
+{{ .AccessModifier }} class {{.Name}} extends {{.VdlComplex}} {
     private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_enum.go b/lib/vdl/codegen/java/file_enum.go
index 50c9752..f24484d 100644
--- a/lib/vdl/codegen/java/file_enum.go
+++ b/lib/vdl/codegen/java/file_enum.go
@@ -20,7 +20,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.VdlEnum {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.VdlEnum {
     {{ range $index, $label := .EnumLabels }}
         @io.v.v23.vdl.GeneratedFromVdl(name = "{{$label}}", index = {{$index}})
         public static final {{$.Name}} {{$label}};
diff --git a/lib/vdl/codegen/java/file_list.go b/lib/vdl/codegen/java/file_list.go
index 06d4c54..84e8d78 100644
--- a/lib/vdl/codegen/java/file_list.go
+++ b/lib/vdl/codegen/java/file_list.go
@@ -20,7 +20,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.VdlList<{{.ElemType}}> {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.VdlList<{{.ElemType}}> {
 	private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_map.go b/lib/vdl/codegen/java/file_map.go
index 073cebb..d32461b 100644
--- a/lib/vdl/codegen/java/file_map.go
+++ b/lib/vdl/codegen/java/file_map.go
@@ -21,7 +21,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.VdlMap<{{.KeyType}}, {{.ElemType}}> {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.VdlMap<{{.KeyType}}, {{.ElemType}}> {
     private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_primitive.go b/lib/vdl/codegen/java/file_primitive.go
index cc167a6..d2db2ff 100644
--- a/lib/vdl/codegen/java/file_primitive.go
+++ b/lib/vdl/codegen/java/file_primitive.go
@@ -21,7 +21,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends {{.VdlType}} {
+{{ .AccessModifier }} class {{.Name}} extends {{.VdlType}} {
 	private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_set.go b/lib/vdl/codegen/java/file_set.go
index 3547163..06c074b 100644
--- a/lib/vdl/codegen/java/file_set.go
+++ b/lib/vdl/codegen/java/file_set.go
@@ -21,7 +21,7 @@
  * {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.VdlSet<{{.KeyType}}> {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.VdlSet<{{.KeyType}}> {
 	private static final long serialVersionUID = 1L;
 
     public static final io.v.v23.vdl.VdlType VDL_TYPE =
diff --git a/lib/vdl/codegen/java/file_struct.go b/lib/vdl/codegen/java/file_struct.go
index a5058f8..4db4d39 100644
--- a/lib/vdl/codegen/java/file_struct.go
+++ b/lib/vdl/codegen/java/file_struct.go
@@ -21,7 +21,7 @@
  * type {{.Name}} {{.VdlTypeString}} {{.Doc}}
  **/
 @io.v.v23.vdl.GeneratedFromVdl(name = "{{.VdlTypeName}}")
-{{ .AccessModifier }} final class {{.Name}} extends io.v.v23.vdl.AbstractVdlStruct {
+{{ .AccessModifier }} class {{.Name}} extends io.v.v23.vdl.AbstractVdlStruct {
     private static final long serialVersionUID = 1L;
 
     {{/* Field declarations */}}