@@ -148,8 +148,11 @@ Checking database and replica set health...
148148Replica set is healthy ✓
149149Running on primary HA node ✓
150150
151- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
152- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
151+ You are about to restore this backup:
152+ Created at: 2020-03-17 16:28:24 +0000 UTC
153+ Controller: how-bizarre
154+ Juju version: 2.7.5
155+ Models: 3
153156
154157All restore pre-checks are completed.
155158
@@ -198,8 +201,11 @@ Checking database and replica set health...
198201Replica set is healthy ✓
199202Running on primary HA node ✓
200203
201- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
202- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
204+ You are about to restore this backup:
205+ Created at: 2020-03-17 16:28:24 +0000 UTC
206+ Controller: how-bizarre
207+ Juju version: 2.7.5
208+ Models: 3
203209
204210All restore pre-checks are completed.
205211
@@ -263,14 +269,15 @@ Checking database and replica set health...
263269Replica set is healthy ✓
264270Running on primary HA node ✓
265271
266- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
267- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
272+ You are about to restore this backup:
273+ Created at: 2020-03-17 16:28:24 +0000 UTC
274+ Controller: how-bizarre
275+ Juju version: 2.7.5
276+ Models: 3
268277
269- This controller is in HA and to restore into it successfully,
270- 'juju-restore' needs to manage Juju and Mongo agents on
271- secondary controller nodes.
272- However, on the bigger systems, the operator might want to manage
273- these agents manually.
278+ This controller is in HA and to restore into it successfully, 'juju-restore'
279+ needs to manage Juju and Mongo agents on secondary controller nodes.
280+ However on bigger systems the user might want to manage these agents manually.
274281
275282Do you want 'juju-restore' to manage these agents automatically? (y/N):
276283
@@ -297,14 +304,15 @@ Checking database and replica set health...
297304Replica set is healthy ✓
298305Running on primary HA node ✓
299306
300- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
301- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
307+ You are about to restore this backup:
308+ Created at: 2020-03-17 16:28:24 +0000 UTC
309+ Controller: how-bizarre
310+ Juju version: 2.7.5
311+ Models: 3
302312
303- This controller is in HA and to restore into it successfully,
304- 'juju-restore' needs to manage Juju and Mongo agents on
305- secondary controller nodes.
306- However, on the bigger systems, the operator might want to manage
307- these agents manually.
313+ This controller is in HA and to restore into it successfully, 'juju-restore'
314+ needs to manage Juju and Mongo agents on secondary controller nodes.
315+ However on bigger systems the user might want to manage these agents manually.
308316
309317Do you want 'juju-restore' to manage these agents automatically? (y/N):
310318
@@ -333,14 +341,15 @@ Checking database and replica set health...
333341Replica set is healthy ✓
334342Running on primary HA node ✓
335343
336- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
337- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
344+ You are about to restore this backup:
345+ Created at: 2020-03-17 16:28:24 +0000 UTC
346+ Controller: how-bizarre
347+ Juju version: 2.7.5
348+ Models: 3
338349
339- This controller is in HA and to restore into it successfully,
340- 'juju-restore' needs to manage Juju and Mongo agents on
341- secondary controller nodes.
342- However, on the bigger systems, the operator might want to manage
343- these agents manually.
350+ This controller is in HA and to restore into it successfully, 'juju-restore'
351+ needs to manage Juju and Mongo agents on secondary controller nodes.
352+ However on bigger systems the user might want to manage these agents manually.
344353
345354Do you want 'juju-restore' to manage these agents automatically? (y/N):
346355All restore pre-checks are completed.
@@ -367,12 +376,15 @@ Checking database and replica set health...
367376Replica set is healthy ✓
368377Running on primary HA node ✓
369378
370- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
371- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
379+ You are about to restore this backup:
380+ Created at: 2020-03-17 16:28:24 +0000 UTC
381+ Controller: how-bizarre
382+ Juju version: 2.7.5
383+ Models: 3
372384
373385Juju agents on secondary controller machines must be stopped by this point.
374386To stop the agents, login into each secondary controller and run:
375- $ systemctl stop jujud-machine-*
387+ $ sudo systemctl stop jujud-machine-*
376388
377389All restore pre-checks are completed.
378390
@@ -412,12 +424,15 @@ Checking database and replica set health...
412424Replica set is healthy ✓
413425Running on primary HA node ✓
414426
415- You are about to restore a controller from a backup file taken on 2020-03-17 16:28:24 +0000 UTC.
416- It contains a controller how-bizarre at Juju version 2.7.5 with 3 models.
427+ You are about to restore this backup:
428+ Created at: 2020-03-17 16:28:24 +0000 UTC
429+ Controller: how-bizarre
430+ Juju version: 2.7.5
431+ Models: 3
417432
418433Juju agents on secondary controller machines must be stopped by this point.
419434To stop the agents, login into each secondary controller and run:
420- $ systemctl stop jujud-machine-*
435+ $ sudo systemctl stop jujud-machine-*
421436
422437All restore pre-checks are completed.
423438
@@ -478,32 +493,53 @@ func (s *restoreSuite) TestLoadsCredsIfNoUsername(c *gc.C) {
478493 c .Assert (err , gc .ErrorMatches , "loading credentials: loading those creds" )
479494}
480495
496+ type readerFunc func (string ) ([]byte , error )
497+
498+ func makeFakeReader (c * gc.C , expectedPath string , contents []byte ) readerFunc {
499+ return func (path string ) ([]byte , error ) {
500+ c .Assert (path , gc .Equals , expectedPath )
501+ return contents , nil
502+ }
503+ }
504+
481505func (s * restoreSuite ) TestReadCredsFromPattern (c * gc.C ) {
482506 dir := c .MkDir ()
483- err := ioutil .WriteFile (filepath .Join (dir , "agent.conf" ), []byte (agentConfContents ), 0777 )
507+ confPath := filepath .Join (dir , "agent.conf" )
508+ err := ioutil .WriteFile (confPath , nil , 0777 )
484509 c .Assert (err , jc .ErrorIsNil )
485510
486- username , password , err := cmd .ReadCredsFromPattern (filepath .Join (dir , "*.conf" ))
511+ username , password , err := cmd .ReadCredsFromPattern (
512+ filepath .Join (dir , "*.conf" ),
513+ makeFakeReader (c , confPath , []byte (agentConfContents )),
514+ )
487515 c .Assert (err , jc .ErrorIsNil )
488516 c .Assert (username , gc .Equals , "porridge-radio" )
489517 c .Assert (password , gc .Equals , "lilac" )
490518}
491519
492520func (s * restoreSuite ) TestReadCredsMissingUsername (c * gc.C ) {
493521 dir := c .MkDir ()
494- err := ioutil .WriteFile (filepath .Join (dir , "agent.conf" ), []byte (missingTagConf ), 0777 )
522+ confPath := filepath .Join (dir , "agent.conf" )
523+ err := ioutil .WriteFile (confPath , nil , 0777 )
495524 c .Assert (err , jc .ErrorIsNil )
496525
497- _ , _ , err = cmd .ReadCredsFromPattern (filepath .Join (dir , "*.conf" ))
526+ _ , _ , err = cmd .ReadCredsFromPattern (
527+ filepath .Join (dir , "*.conf" ),
528+ makeFakeReader (c , confPath , []byte (missingTagConf )),
529+ )
498530 c .Assert (err , gc .ErrorMatches , `no username found in ".*/agent\.conf" - tag field is missing or blank` )
499531}
500532
501533func (s * restoreSuite ) TestReadCredsMissingPassword (c * gc.C ) {
502534 dir := c .MkDir ()
503- err := ioutil .WriteFile (filepath .Join (dir , "agent.conf" ), []byte (missingPasswordConf ), 0777 )
535+ confPath := filepath .Join (dir , "agent.conf" )
536+ err := ioutil .WriteFile (confPath , nil , 0777 )
504537 c .Assert (err , jc .ErrorIsNil )
505538
506- _ , _ , err = cmd .ReadCredsFromPattern (filepath .Join (dir , "*.conf" ))
539+ _ , _ , err = cmd .ReadCredsFromPattern (
540+ filepath .Join (dir , "*.conf" ),
541+ makeFakeReader (c , confPath , []byte (missingPasswordConf )),
542+ )
507543 c .Assert (err , gc .ErrorMatches , `no password found in ".*/agent\.conf" - statepassword field is missing or blank` )
508544}
509545
0 commit comments