github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/chore/e2e/run/reboot.go (about) 1 package main 2 3 import ( 4 "context" 5 "fmt" 6 "time" 7 8 "github.com/caos/orbos/internal/operator/common" 9 ) 10 11 var _ testFunc = reboot 12 13 func reboot(_ *testSpecs, settings programSettings, conditions *conditions) interactFunc { 14 15 return func(ctx context.Context, _ uint8, orbctl newOrbctlCommandFunc) error { 16 17 rebootCtx, rebootCancel := context.WithTimeout(ctx, 1*time.Minute) 18 defer rebootCancel() 19 20 since := time.Now() 21 22 nodeContext, nodeID, err := someMasterNodeContextAndID(rebootCtx, settings, orbctl) 23 if err != nil { 24 return err 25 } 26 27 // as we don't know the time when a skipped test was run originally (variable "since"), we can't check this anymore in downstream tests. 28 conditions.testCase = &condition{ 29 watcher: watch(10*time.Minute, orbiter), 30 checks: func(_ context.Context, _ newKubectlCommandFunc, _ currentOrbiter, current common.NodeAgentsCurrentKind) error { 31 nodeagent, ok := current.Current.Get(nodeID) 32 if !ok { 33 return fmt.Errorf("nodeagent %s not found", nodeID) 34 } 35 if nodeagent.Booted.Before(since) { 36 return fmt.Errorf("nodeagent %s has latest boot at %s which is before %s", nodeID, nodeagent.Booted.Format(time.RFC822), since.Format(time.RFC822)) 37 } 38 return nil 39 }, 40 } 41 42 return runCommand(settings, orbiter.strPtr(), nil, nil, orbctl(rebootCtx), "--gitops", "node", "reboot", fmt.Sprintf("%s.%s", nodeContext, nodeID)) 43 } 44 }