github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/chore/e2e/run/replace.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 = replace
    12  
    13  func replace(_ *testSpecs, settings programSettings, conditions *conditions) interactFunc {
    14  	return func(ctx context.Context, _ uint8, newOrbctl newOrbctlCommandFunc) error {
    15  
    16  		replaceCtx, replaceCancel := context.WithTimeout(ctx, 1*time.Minute)
    17  		defer replaceCancel()
    18  
    19  		nodeContext, nodeID, err := someMasterNodeContextAndID(replaceCtx, settings, newOrbctl)
    20  		if err != nil {
    21  			return err
    22  		}
    23  
    24  		// as we don't know the machines name that a skipped test replaced originally (variable "nodeID"), we can't check this anymore in downstream tests.
    25  		conditions.testCase = &condition{
    26  			watcher: watch(20*time.Minute, orbiter),
    27  			checks: func(_ context.Context, _ newKubectlCommandFunc, _ currentOrbiter, current common.NodeAgentsCurrentKind) error {
    28  				_, ok := current.Current.Get(nodeID)
    29  				if ok {
    30  					return fmt.Errorf("nodeagent %s still has a current state", nodeID)
    31  				}
    32  				return nil
    33  			},
    34  		}
    35  
    36  		return runCommand(settings, orbctl.strPtr(), nil, nil, newOrbctl(replaceCtx), "--gitops", "node", "replace", fmt.Sprintf("%s.%s", nodeContext, nodeID))
    37  	}
    38  }