blob: 6ec6e37111d02b8bc1f4bb5f34dc6b758c74fb01 [file] [log] [blame]
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -07001package flags_test
2
3import (
4 "flag"
Cosmos Nicolaou4e213d72014-10-26 22:21:52 -07005 "io/ioutil"
Cosmos Nicolaoud811b072014-10-28 17:46:27 -07006 "os"
7 "reflect"
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -07008 "testing"
9
Jiri Simsa764efb72014-12-25 20:57:03 -080010 "v.io/core/veyron/lib/flags"
11 "v.io/core/veyron/lib/flags/consts"
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -070012)
13
14func TestFlags(t *testing.T) {
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070015 fs := flag.NewFlagSet("test", flag.ContinueOnError)
16 if flags.CreateAndRegister(fs) != nil {
Cosmos Nicolaou78237372014-11-04 18:19:09 -080017 t.Fatalf("should have returned a nil value")
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070018 }
19 fl := flags.CreateAndRegister(fs, flags.Runtime)
20 if fl == nil {
Bogdan Capritabf356d72015-01-08 17:28:48 -080021 t.Errorf("should have succeeded")
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070022 }
Cosmos Nicolaoud811b072014-10-28 17:46:27 -070023 creds := "creddir"
24 roots := []string{"ab:cd:ef"}
25 args := []string{"--veyron.credentials=" + creds, "--veyron.namespace.root=" + roots[0]}
Bogdan Capritabf356d72015-01-08 17:28:48 -080026 fl.Parse(args, nil)
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070027 rtf := fl.RuntimeFlags()
28 if got, want := rtf.NamespaceRoots, roots; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -070029 t.Errorf("got %v, want %v", got, want)
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -070030 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070031 if got, want := rtf.Credentials, creds; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -070032 t.Errorf("got %v, want %v", got, want)
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -070033 }
Cosmos Nicolaoud811b072014-10-28 17:46:27 -070034 if got, want := fl.HasGroup(flags.Listen), false; got != want {
35 t.Errorf("got %t, want %t", got, want)
36 }
37 // Make sure we have a deep copy.
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070038 rtf.NamespaceRoots[0] = "oooh"
39 rtf = fl.RuntimeFlags()
40 if got, want := rtf.NamespaceRoots, roots; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -070041 t.Errorf("got %v, want %v", got, want)
Cosmos Nicolaou4e213d72014-10-26 22:21:52 -070042 }
43}
44
Cosmos Nicolaou78237372014-11-04 18:19:09 -080045func TestACLFlags(t *testing.T) {
46 fs := flag.NewFlagSet("test", flag.ContinueOnError)
47 fl := flags.CreateAndRegister(fs, flags.Runtime, flags.ACL)
Robert Kroeger5096c4b2014-12-10 15:08:45 -080048 args := []string{"--veyron.acl.file=runtime:foo.json", "--veyron.acl.file=bar:bar.json", "--veyron.acl.file=baz:bar:baz.json"}
Bogdan Capritabf356d72015-01-08 17:28:48 -080049 fl.Parse(args, nil)
Cosmos Nicolaou78237372014-11-04 18:19:09 -080050 aclf := fl.ACLFlags()
Robert Kroeger5096c4b2014-12-10 15:08:45 -080051
Cosmos Nicolaouc7ddcf02014-11-05 16:26:56 -080052 if got, want := aclf.ACLFile("runtime"), "foo.json"; got != want {
Cosmos Nicolaou78237372014-11-04 18:19:09 -080053 t.Errorf("got %t, want %t", got, want)
54 }
55 if got, want := aclf.ACLFile("bar"), "bar.json"; got != want {
56 t.Errorf("got %t, want %t", got, want)
57 }
58 if got, want := aclf.ACLFile("wombat"), ""; got != want {
59 t.Errorf("got %t, want %t", got, want)
60 }
61 if got, want := aclf.ACLFile("baz"), "bar:baz.json"; got != want {
62 t.Errorf("got %t, want %t", got, want)
63 }
64}
65
Robert Kroeger5096c4b2014-12-10 15:08:45 -080066func TestACLLiteralFlags(t *testing.T) {
67 fs := flag.NewFlagSet("test", flag.ContinueOnError)
68 fl := flags.CreateAndRegister(fs, flags.Runtime, flags.ACL)
69 args := []string{"--veyron.acl.literal=hedgehog"}
Bogdan Capritabf356d72015-01-08 17:28:48 -080070 fl.Parse(args, nil)
Robert Kroeger5096c4b2014-12-10 15:08:45 -080071 aclf := fl.ACLFlags()
72
73 if got, want := aclf.ACLFile("runtime"), ""; got != want {
74 t.Errorf("got %t, want %t", got, want)
75 }
76 if got, want := aclf.ACLLiteral(), "hedgehog"; got != want {
77 t.Errorf("got %t, want %t, ok %t", got, want)
78 }
79}
80
81func TestACLLiteralBoth(t *testing.T) {
82 fs := flag.NewFlagSet("test", flag.ContinueOnError)
83 fl := flags.CreateAndRegister(fs, flags.Runtime, flags.ACL)
84 args := []string{"--veyron.acl.file=runtime:foo.json", "--veyron.acl.literal=hedgehog"}
Bogdan Capritabf356d72015-01-08 17:28:48 -080085 fl.Parse(args, nil)
Robert Kroeger5096c4b2014-12-10 15:08:45 -080086 aclf := fl.ACLFlags()
87
88 if got, want := aclf.ACLFile("runtime"), "foo.json"; got != want {
89 t.Errorf("got %t, want %t", got, want)
90 }
91 if got, want := aclf.ACLLiteral(), "hedgehog"; got != want {
92 t.Errorf("got %t, want %t, ok %t", got, want)
93 }
94}
95
Cosmos Nicolaou4e213d72014-10-26 22:21:52 -070096func TestFlagError(t *testing.T) {
97 fs := flag.NewFlagSet("test", flag.ContinueOnError)
98 fs.SetOutput(ioutil.Discard)
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -070099 fl := flags.CreateAndRegister(fs, flags.Runtime)
Cosmos Nicolaou4e213d72014-10-26 22:21:52 -0700100 addr := "192.168.10.1:0"
101 args := []string{"--xxxveyron.tcp.address=" + addr, "not an arg"}
Bogdan Capritabf356d72015-01-08 17:28:48 -0800102 err := fl.Parse(args, nil)
Cosmos Nicolaou4e213d72014-10-26 22:21:52 -0700103 if err == nil {
104 t.Fatalf("expected this to fail!")
105 }
106 if got, want := len(fl.Args()), 1; got != want {
107 t.Errorf("got %d, want %d [args: %v]", got, want, fl.Args())
108 }
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800109
110 fs = flag.NewFlagSet("test", flag.ContinueOnError)
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800111 fl = flags.CreateAndRegister(fs, flags.ACL)
Robert Kroeger5096c4b2014-12-10 15:08:45 -0800112 args = []string{"--veyron.acl.file=noname"}
Bogdan Capritabf356d72015-01-08 17:28:48 -0800113 err = fl.Parse(args, nil)
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800114 if err == nil {
115 t.Fatalf("expected this to fail!")
116 }
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700117}
118
119func TestFlagsGroups(t *testing.T) {
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700120 fl := flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Runtime, flags.Listen)
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700121 if got, want := fl.HasGroup(flags.Listen), true; got != want {
122 t.Errorf("got %t, want %t", got, want)
123 }
124 addr := "192.168.10.1:0"
125 roots := []string{"ab:cd:ef"}
126 args := []string{"--veyron.tcp.address=" + addr, "--veyron.namespace.root=" + roots[0]}
Bogdan Capritabf356d72015-01-08 17:28:48 -0800127 fl.Parse(args, nil)
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700128 lf := fl.ListenFlags()
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700129 if got, want := fl.RuntimeFlags().NamespaceRoots, roots; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700130 t.Errorf("got %v, want %v", got, want)
131 }
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800132 if got, want := lf.Addrs[0].Address, addr; got != want {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700133 t.Errorf("got %q, want %q", got, want)
134 }
135}
136
Asim Shankar95910b62014-10-31 22:02:29 -0700137const (
138 rootEnvVar = consts.NamespaceRootPrefix
139 rootEnvVar0 = consts.NamespaceRootPrefix + "0"
140)
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700141
142func TestEnvVars(t *testing.T) {
Asim Shankar95910b62014-10-31 22:02:29 -0700143 oldcreds := os.Getenv(consts.VeyronCredentials)
144 defer os.Setenv(consts.VeyronCredentials, oldcreds)
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700145
146 oldroot := os.Getenv(rootEnvVar)
147 oldroot0 := os.Getenv(rootEnvVar0)
148 defer os.Setenv(rootEnvVar, oldroot)
149 defer os.Setenv(rootEnvVar0, oldroot0)
150
Asim Shankar95910b62014-10-31 22:02:29 -0700151 os.Setenv(consts.VeyronCredentials, "bar")
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700152 fl := flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Runtime)
Bogdan Capritabf356d72015-01-08 17:28:48 -0800153 if err := fl.Parse([]string{}, nil); err != nil {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700154 t.Fatalf("unexpected error: %s", err)
155 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700156 rtf := fl.RuntimeFlags()
157 if got, want := rtf.Credentials, "bar"; got != want {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700158 t.Errorf("got %q, want %q", got, want)
159 }
160
Bogdan Capritabf356d72015-01-08 17:28:48 -0800161 if err := fl.Parse([]string{"--veyron.credentials=baz"}, nil); err != nil {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700162 t.Fatalf("unexpected error: %s", err)
163 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700164 rtf = fl.RuntimeFlags()
165 if got, want := rtf.Credentials, "baz"; got != want {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700166 t.Errorf("got %q, want %q", got, want)
167 }
168
169 os.Setenv(rootEnvVar, "a:1")
170 os.Setenv(rootEnvVar0, "a:2")
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700171 fl = flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Runtime)
Bogdan Capritabf356d72015-01-08 17:28:48 -0800172 if err := fl.Parse([]string{}, nil); err != nil {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700173 t.Fatalf("unexpected error: %s", err)
174 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700175 rtf = fl.RuntimeFlags()
176 if got, want := rtf.NamespaceRoots, []string{"a:1", "a:2"}; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700177 t.Errorf("got %q, want %q", got, want)
178 }
Bogdan Capritabf356d72015-01-08 17:28:48 -0800179 if err := fl.Parse([]string{"--veyron.namespace.root=b:1", "--veyron.namespace.root=b:2", "--veyron.namespace.root=b:3", "--veyron.credentials=b:4"}, nil); err != nil {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700180 t.Fatalf("unexpected error: %s", err)
181 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700182 rtf = fl.RuntimeFlags()
183 if got, want := rtf.NamespaceRoots, []string{"b:1", "b:2", "b:3"}; !reflect.DeepEqual(got, want) {
Cosmos Nicolaoud811b072014-10-28 17:46:27 -0700184 t.Errorf("got %q, want %q", got, want)
185 }
Cosmos Nicolaoue5b41502014-10-29 22:55:09 -0700186 if got, want := rtf.Credentials, "b:4"; got != want {
187 t.Errorf("got %q, want %q", got, want)
188 }
Cosmos Nicolaoubdc917c2014-10-24 12:41:47 -0700189}
Cosmos Nicolaou98960042014-10-31 00:05:51 -0700190
191func TestDefaults(t *testing.T) {
192 oldroot := os.Getenv(rootEnvVar)
193 oldroot0 := os.Getenv(rootEnvVar0)
194 defer os.Setenv(rootEnvVar, oldroot)
195 defer os.Setenv(rootEnvVar0, oldroot0)
196
197 os.Setenv(rootEnvVar, "")
198 os.Setenv(rootEnvVar0, "")
199
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800200 fl := flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Runtime, flags.ACL)
Bogdan Capritabf356d72015-01-08 17:28:48 -0800201 if err := fl.Parse([]string{}, nil); err != nil {
Cosmos Nicolaou98960042014-10-31 00:05:51 -0700202 t.Fatalf("unexpected error: %s", err)
203 }
204 rtf := fl.RuntimeFlags()
Robin Thellend8fea01c2014-12-11 13:48:10 -0800205 if got, want := rtf.NamespaceRoots, []string{"/ns.dev.v.io:8101"}; !reflect.DeepEqual(got, want) {
Cosmos Nicolaou98960042014-10-31 00:05:51 -0700206 t.Errorf("got %q, want %q", got, want)
207 }
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800208 aclf := fl.ACLFlags()
Cosmos Nicolaouc7ddcf02014-11-05 16:26:56 -0800209 if got, want := aclf.ACLFile(""), ""; got != want {
Cosmos Nicolaou78237372014-11-04 18:19:09 -0800210 t.Errorf("got %q, want %q", got, want)
211 }
Cosmos Nicolaou98960042014-10-31 00:05:51 -0700212}
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800213
214func TestListenFlags(t *testing.T) {
215 fl := flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Listen)
Bogdan Capritabf356d72015-01-08 17:28:48 -0800216 if err := fl.Parse([]string{}, nil); err != nil {
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800217 t.Fatalf("unexpected error: %s", err)
218 }
219 lf := fl.ListenFlags()
220 if got, want := len(lf.Addrs), 1; got != want {
221 t.Errorf("got %d, want %d", got, want)
222 }
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800223
224 // Test the default protocol and address is "wsh" and ":0".
225 def := struct{ Protocol, Address string }{"wsh", ":0"}
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800226 if got, want := lf.Addrs[0], def; !reflect.DeepEqual(got, want) {
227 t.Errorf("got %v, want %v", got, want)
228 }
229
230 fl = flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Listen)
231 if err := fl.Parse([]string{
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800232 "--veyron.tcp.address=172.0.0.1:10", // Will default to protocol "wsh".
233 "--veyron.tcp.protocol=tcp", "--veyron.tcp.address=127.0.0.10:34",
234 "--veyron.tcp.protocol=ws4", "--veyron.tcp.address=127.0.0.10:44",
235 "--veyron.tcp.protocol=tcp6", "--veyron.tcp.address=172.0.0.100:100"}, nil); err != nil {
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800236 t.Fatalf("unexpected error: %s", err)
237 }
238 lf = fl.ListenFlags()
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800239 if got, want := len(lf.Addrs), 4; got != want {
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800240 t.Errorf("got %d, want %d", got, want)
241 }
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800242 for i, p := range []string{"wsh", "tcp", "ws4", "tcp6"} {
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800243 if got, want := lf.Addrs[i].Protocol, p; got != want {
244 t.Errorf("got %q, want %q", got, want)
245 }
246 }
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800247 for i, p := range []string{"172.0.0.1:10", "127.0.0.10:34", "127.0.0.10:44", "172.0.0.100:100"} {
Cosmos Nicolaouae8dd212014-12-13 23:43:08 -0800248 if got, want := lf.Addrs[i].Address, p; got != want {
249 t.Errorf("got %q, want %q", got, want)
250 }
251 }
252}
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800253
254func TestDuplicateFlags(t *testing.T) {
255 fl := flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Listen)
256 if err := fl.Parse([]string{
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800257 "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:34",
258 "--veyron.tcp.protocol=tcp", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:34",
259 "--veyron.tcp.protocol=ws", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:34", "--veyron.tcp.address=172.0.0.1:34"}, nil); err != nil {
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800260 t.Fatalf("unexpected error: %s", err)
261 }
262 lf := fl.ListenFlags()
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800263 if got, want := len(lf.Addrs), 6; got != want {
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800264 t.Errorf("got %d, want %d", got, want)
265 }
266 expected := flags.ListenAddrs{
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800267 {"wsh", "172.0.0.1:10"},
268 {"wsh", "172.0.0.1:34"},
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800269 {"tcp", "172.0.0.1:10"},
270 {"tcp", "172.0.0.1:34"},
271 {"ws", "172.0.0.1:10"},
272 {"ws", "172.0.0.1:34"},
273 }
274 if got, want := lf.Addrs, expected; !reflect.DeepEqual(got, want) {
275 t.Fatalf("got %#v, want %#v", got, want)
276 }
277 if err := fl.Parse([]string{
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800278 "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=172.0.0.1:34",
279 "--veyron.tcp.protocol=tcp", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=127.0.0.1:34", "--veyron.tcp.address=127.0.0.1:34",
280 "--veyron.tcp.protocol=ws", "--veyron.tcp.address=172.0.0.1:10", "--veyron.tcp.address=127.0.0.1:34", "--veyron.tcp.address=127.0.0.1:34"}, nil); err != nil {
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800281 t.Fatalf("unexpected error: %s", err)
282 }
Nicolas LaCasse29d1d3a2015-01-22 10:48:18 -0800283 if got, want := len(lf.Addrs), 6; got != want {
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800284 t.Errorf("got %d, want %d", got, want)
285 }
286 if got, want := lf.Addrs, expected; !reflect.DeepEqual(got, want) {
287 t.Fatalf("got %#v, want %#v", got, want)
288 }
289
290 fl = flags.CreateAndRegister(flag.NewFlagSet("test", flag.ContinueOnError), flags.Runtime)
291
Bogdan Capritabf356d72015-01-08 17:28:48 -0800292 if err := fl.Parse([]string{"--veyron.namespace.root=ab", "--veyron.namespace.root=xy", "--veyron.namespace.root=ab"}, nil); err != nil {
Cosmos Nicolaou96fa9172014-12-16 12:57:18 -0800293 t.Fatalf("unexpected error: %s", err)
294 }
295
296 rf := fl.RuntimeFlags()
297 if got, want := len(rf.NamespaceRoots), 2; got != want {
298 t.Errorf("got %d, want %d", got, want)
299 }
300 if got, want := rf.NamespaceRoots, []string{"ab", "xy"}; !reflect.DeepEqual(got, want) {
301 t.Fatalf("got %#v, want %#v", got, want)
302 }
303}
Bogdan Capritabf356d72015-01-08 17:28:48 -0800304
305func TestConfig(t *testing.T) {
306 fs := flag.NewFlagSet("test", flag.ContinueOnError)
307 var testFlag1, testFlag2 string
308 fs.StringVar(&testFlag1, "test_flag1", "default1", "")
309 fs.StringVar(&testFlag2, "test_flag2", "default2", "")
310 fl := flags.CreateAndRegister(fs, flags.Runtime)
311 args := []string{
312 "--veyron.namespace.root=argRoot1",
313 "--veyron.namespace.root=argRoot2",
314 "--veyron.vtrace.cache_size=1234",
315 }
316 config := map[string]string{
317 "veyron.namespace.root": "configRoot",
318 "veyron.credentials": "configCreds",
319 "veyron.vtrace.cache_size": "4321",
320 "test_flag1": "test value",
321 "flag.that.does.not.exist": "some value",
322 }
323 if err := fl.Parse(args, config); err != nil {
324 t.Errorf("Parse(%v, %v) failed: %v", args, config, err)
325 }
326 rtf := fl.RuntimeFlags()
327 if got, want := rtf.NamespaceRoots, []string{"argRoot1", "argRoot2", "configRoot"}; !reflect.DeepEqual(got, want) {
328 t.Errorf("Namespace roots: got %v, want %v", got, want)
329 }
330 if got, want := rtf.Credentials, "configCreds"; got != want {
331 t.Errorf("Credentials: got %v, want %v", got, want)
332 }
333 if got, want := testFlag1, "test value"; got != want {
334 t.Errorf("Test flag 1: got %v, want %v", got, want)
335 }
336 if got, want := testFlag2, "default2"; got != want {
337 t.Errorf("Test flag 2: got %v, want %v", got, want)
338 }
339 if got, want := rtf.Vtrace.CacheSize, 4321; got != want {
340 t.Errorf("Test flag 2: got %v, want %v", got, want)
341 }
342}