@@ -325,3 +325,63 @@ func TestRktDriverUser(t *testing.T) {
325
325
t .Fatalf ("Expecting '%v' in '%v'" , msg , err )
326
326
}
327
327
}
328
+
329
+ func TestRktTrustPrefix (t * testing.T ) {
330
+ if os .Getenv ("NOMAD_TEST_RKT" ) == "" {
331
+ t .Skip ("skipping rkt tests" )
332
+ }
333
+ ctestutils .RktCompatible (t )
334
+ task := & structs.Task {
335
+ Name : "etcd" ,
336
+ Config : map [string ]interface {}{
337
+ "trust_prefix" : "example.com/invalid" ,
338
+ "image" : "coreos.com/etcd:v2.0.4" ,
339
+ "command" : "/etcd" ,
340
+ "args" : []string {"--version" },
341
+ },
342
+ LogConfig : & structs.LogConfig {
343
+ MaxFiles : 10 ,
344
+ MaxFileSizeMB : 10 ,
345
+ },
346
+ Resources : & structs.Resources {
347
+ MemoryMB : 128 ,
348
+ CPU : 100 ,
349
+ },
350
+ }
351
+ driverCtx , execCtx := testDriverContexts (task )
352
+ defer execCtx .AllocDir .Destroy ()
353
+
354
+ d := NewRktDriver (driverCtx )
355
+
356
+ handle , err := d .Start (execCtx , task )
357
+ if err == nil {
358
+ handle .Kill ()
359
+ t .Fatalf ("Should've failed" )
360
+ }
361
+ msg := "Error running rkt trust"
362
+ if ! strings .Contains (err .Error (), msg ) {
363
+ t .Fatalf ("Expecting '%v' in '%v'" , msg , err )
364
+ }
365
+ }
366
+
367
+ func TestRktTaskValidate (t * testing.T ) {
368
+ ctestutils .RktCompatible (t )
369
+ task := & structs.Task {
370
+ Name : "etcd" ,
371
+ Config : map [string ]interface {}{
372
+ "trust_prefix" : "coreos.com/etcd" ,
373
+ "image" : "coreos.com/etcd:v2.0.4" ,
374
+ "command" : "/etcd" ,
375
+ "args" : []string {"--version" },
376
+ "dns_servers" : []string {"8.8.8.8" , "8.8.4.4" },
377
+ "dns_search_domains" : []string {"example.com" , "example.org" , "example.net" },
378
+ },
379
+ }
380
+ driverCtx , execCtx := testDriverContexts (task )
381
+ defer execCtx .AllocDir .Destroy ()
382
+
383
+ d := NewRktDriver (driverCtx )
384
+ if err := d .Validate (task .Config ); err != nil {
385
+ t .Fatalf ("Validation error in TaskConfig : '%v'" , err )
386
+ }
387
+ }
0 commit comments