Commit 262cd7de authored by Roberto Bonafiglia's avatar Roberto Bonafiglia Committed by Roberto Bonafiglia

Added IPv6 check and agent restart on e2e test utils

parent 15ee8896
...@@ -415,6 +415,17 @@ func RestartCluster(nodeNames []string) error { ...@@ -415,6 +415,17 @@ func RestartCluster(nodeNames []string) error {
return nil return nil
} }
// RestartCluster restarts the k3s service on each node given
func RestartClusterAgent(nodeNames []string) error {
for _, nodeName := range nodeNames {
cmd := "sudo systemctl restart k3s-agent"
if _, err := RunCmdOnNode(cmd, nodeName); err != nil {
return err
}
}
return nil
}
// RunCmdOnNode executes a command from within the given node // RunCmdOnNode executes a command from within the given node
func RunCmdOnNode(cmd string, nodename string) (string, error) { func RunCmdOnNode(cmd string, nodename string) (string, error) {
runcmd := "vagrant ssh -c \"" + cmd + "\" " + nodename runcmd := "vagrant ssh -c \"" + cmd + "\" " + nodename
...@@ -477,7 +488,11 @@ func GetObjIPs(cmd string) ([]ObjIP, error) { ...@@ -477,7 +488,11 @@ func GetObjIPs(cmd string) ([]ObjIP, error) {
if len(fields) > 2 { if len(fields) > 2 {
objIPs = append(objIPs, ObjIP{Name: fields[0], IPv4: fields[1], IPv6: fields[2]}) objIPs = append(objIPs, ObjIP{Name: fields[0], IPv4: fields[1], IPv6: fields[2]})
} else if len(fields) > 1 { } else if len(fields) > 1 {
objIPs = append(objIPs, ObjIP{Name: fields[0], IPv4: fields[1]}) if strings.Contains(fields[1], ".") {
objIPs = append(objIPs, ObjIP{Name: fields[0], IPv4: fields[1]})
} else {
objIPs = append(objIPs, ObjIP{Name: fields[0], IPv6: fields[1]})
}
} else { } else {
objIPs = append(objIPs, ObjIP{Name: fields[0]}) objIPs = append(objIPs, ObjIP{Name: fields[0]})
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment