rancher / qa-tasks

List of QA Backlog
1 stars 1 forks source link

Change the control flow for arguments by adding a capability to not rely on RunOnNode or RunOnHost #800

Closed fmoral2 closed 1 year ago

fmoral2 commented 1 year ago

Related to epic rancher/qa-tasks#799

fmoral2 commented 1 year ago

Complexity label:

1 generally easier      - should take no more than 1 work day
2 middle                - term should take no more than 3 work days
3 complex               - should take ~ 5 work days
4 jedi                  - should take ~ 10 work days
fmoral2 commented 1 year ago

Label: 3

fmoral2 commented 1 year ago

Details of the implementation :

type RunCmd struct { Run []TestMap }

type TestMap struct { Cmd string ExpectedValue string ExpectedValueUpgrade string Description string }


template changed to this 
    template.VersionTemplate(template.VersionTestTemplate{
        Description: template.TestMapFlag.Description,
        TestCombination: &template.RunCmd{
            Run: []template.TestMap{
                {
                    Cmd:                  template.TestMapFlag.Cmd,
                    ExpectedValue:        template.TestMapFlag.ExpectedValue,
                    ExpectedValueUpgrade: template.TestMapFlag.ExpectedValueUpgrade,
                },
            },
        },
        InstallUpgrade: customflag.ServiceFlag.InstallUpgrade,
        TestConfig: &template.TestConfig{
            TestFunc:       template.TestCase(customflag.ServiceFlag.TestCase.TestFunc),
            DeployWorkload: customflag.ServiceFlag.TestCase.DeployWorkload,
        },
    })
})

processor changed to thjis : 

func processTestCombination(resultChan chan error, wg *sync.WaitGroup, ips []string, testCombination RunCmd) { for , ip := range ips { if testCombination.Run != nil { for , testMap := range testCombination.Run { if strings.Contains(testMap.Cmd, "kubectl") { wg.Add(1) go func(ip string, cmd, expectedValue, expectedValueUpgraded string) { defer wg.Done() defer GinkgoRecover() processOnHost(resultChan, ip, cmd, expectedValue) }(ip, testMap.Cmd, testMap.ExpectedValue, testMap.ExpectedValueUpgrade) } else { wg.Add(1) go func(ip string, cmd, expectedValue string) { defer wg.Done() defer GinkgoRecover() processOnNode(resultChan, ip, cmd, expectedValue) }(ip, testMap.Cmd, testMap.ExpectedValue) } } } } }



In this wat we cand send an arg like  : 

`go test ....... -cmd`    instead of  `go test ..... -cmdNode  ..... -cmdHost`

So we basically changed the code to handle this instead of user.
fmoral2 commented 1 year ago

https://github.com/fmoral2/k3s/tree/fmoral2.800-control-flow

https://github.com/fmoral2/rke2/tree/fmoral2.800-control