element_type
stringclasses
4 values
project_name
stringclasses
1 value
uuid
stringlengths
36
36
name
stringlengths
0
346
imports
stringlengths
0
2.67k
structs
stringclasses
761 values
interfaces
stringclasses
22 values
file_location
stringclasses
545 values
code
stringlengths
26
8.07M
global_vars
stringclasses
7 values
package
stringclasses
124 values
tags
stringclasses
1 value
function
openshift/openshift-tests-private
c42818b1-7b3b-4796-b52e-0ec7aa553186
createIPBlockMultipleCIDRsObjectSingle
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['ipBlockCIDRsSingle']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (ipBlock_cidrs_policy *ipBlockCIDRsSingle) createIPBlockMultipleCIDRsObjectSingle(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplateByAdmin(oc, "--ignore-unknown-parameters=true", "-f", ipBlock_cidrs_policy.template, "-p", "NAME="+ipBlock_cidrs_policy.name, "NAMESPACE="+ipBlock_cidrs_policy.namespace, "CIDR="+ipBlock_cidrs_policy.cidr, "CIDR2="+ipBlock_cidrs_policy.cidr2, "CIDR3="+ipBlock_cidrs_policy.cidr3) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create network policy %v", ipBlock_cidrs_policy.name)) }
networking
function
openshift/openshift-tests-private
019d3f3d-e975-4379-bece-6cbc36b91920
createServiceFromParams
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['genericServiceResource']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (service *genericServiceResource) createServiceFromParams(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplateByAdmin(oc, "--ignore-unknown-parameters=true", "-f", service.template, "-p", "SERVICENAME="+service.servicename, "NAMESPACE="+service.namespace, "PROTOCOL="+service.protocol, "SELECTOR="+service.selector, "serviceType="+service.serviceType, "ipFamilyPolicy="+service.ipFamilyPolicy, "internalTrafficPolicy="+service.internalTrafficPolicy, "externalTrafficPolicy="+service.externalTrafficPolicy) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create svc %v", service.servicename)) }
networking
function
openshift/openshift-tests-private
003c8cd4-fc2b-4412-b63a-e8026d5e953d
createWinServiceFromParams
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['windowGenericServiceResource']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (service *windowGenericServiceResource) createWinServiceFromParams(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplateByAdmin(oc, "--ignore-unknown-parameters=true", "-f", service.template, "-p", "SERVICENAME="+service.servicename, "NAMESPACE="+service.namespace, "PROTOCOL="+service.protocol, "SELECTOR="+service.selector, "serviceType="+service.serviceType, "ipFamilyPolicy="+service.ipFamilyPolicy, "internalTrafficPolicy="+service.internalTrafficPolicy, "externalTrafficPolicy="+service.externalTrafficPolicy) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create svc %v", service.servicename)) }
networking
function
openshift/openshift-tests-private
83564720-c819-4e84-b1ca-65f64faf9f40
createEgressRouterMultipeDst
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['egressrouterMultipleDst']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (egressrouter *egressrouterMultipleDst) createEgressRouterMultipeDst(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplateByAdmin(oc, "--ignore-unknown-parameters=true", "-f", egressrouter.template, "-p", "NAME="+egressrouter.name, "NAMESPACE="+egressrouter.namespace, "RESERVEDIP="+egressrouter.reservedip, "GATEWAY="+egressrouter.gateway, "DSTIP1="+egressrouter.destinationip1, "DSTIP2="+egressrouter.destinationip2, "DSTIP3="+egressrouter.destinationip3) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create egressrouter %v", egressrouter.name)) }
networking
function
openshift/openshift-tests-private
a732d361-ac62-4ada-ac88-71caef1249f2
createEgressRouterRedSDN
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['egressrouterRedSDN']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (egressrouter *egressrouterRedSDN) createEgressRouterRedSDN(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplateByAdmin(oc, "--ignore-unknown-parameters=true", "-f", egressrouter.template, "-p", "NAME="+egressrouter.name, "NAMESPACE="+egressrouter.namespace, "RESERVEDIP="+egressrouter.reservedip, "GATEWAY="+egressrouter.gateway, "DSTIP="+egressrouter.destinationip, "LABELKEY="+egressrouter.labelkey, "LABELVALUE="+egressrouter.labelvalue) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create egressrouter %v", egressrouter.name)) }
networking
function
openshift/openshift-tests-private
2918762b-b2b3-451c-9e94-d28660bf73c0
deleteEgressFW2Object
['egressFirewall2']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (egressFirewall *egressFirewall2) deleteEgressFW2Object(oc *exutil.CLI) { removeResource(oc, true, true, "egressfirewall", egressFirewall.name, "-n", egressFirewall.namespace) }
networking
function
openshift/openshift-tests-private
f15dbc30-618f-4e5c-8f7e-e86275ec3957
deletePingPod
['pingPodResource']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (pod *pingPodResource) deletePingPod(oc *exutil.CLI) { removeResource(oc, false, true, "pod", pod.name, "-n", pod.namespace) }
networking
function
openshift/openshift-tests-private
51a04ffe-b876-4ad0-b217-01a865695d0e
deletePingPodNode
['pingPodResourceNode']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (pod *pingPodResourceNode) deletePingPodNode(oc *exutil.CLI) { removeResource(oc, false, true, "pod", pod.name, "-n", pod.namespace) }
networking
function
openshift/openshift-tests-private
ad2f5eb6-ff9f-494e-a837-22972bdd7478
removeResource
['"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func removeResource(oc *exutil.CLI, asAdmin bool, withoutNamespace bool, parameters ...string) { output, err := doAction(oc, "delete", asAdmin, withoutNamespace, parameters...) if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) { e2e.Logf("the resource is deleted already") return } o.Expect(err).NotTo(o.HaveOccurred()) err = wait.Poll(3*time.Second, 120*time.Second, func() (bool, error) { output, err := doAction(oc, "get", asAdmin, withoutNamespace, parameters...) if err != nil && (strings.Contains(output, "NotFound") || strings.Contains(output, "No resources found")) { e2e.Logf("the resource is delete successfully") return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to delete resource %v", parameters)) }
networking
function
openshift/openshift-tests-private
19e3103b-780e-40d5-a40b-dbf17e422de6
doAction
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func doAction(oc *exutil.CLI, action string, asAdmin bool, withoutNamespace bool, parameters ...string) (string, error) { if asAdmin && withoutNamespace { return oc.AsAdmin().WithoutNamespace().Run(action).Args(parameters...).Output() } if asAdmin && !withoutNamespace { return oc.AsAdmin().Run(action).Args(parameters...).Output() } if !asAdmin && withoutNamespace { return oc.WithoutNamespace().Run(action).Args(parameters...).Output() } if !asAdmin && !withoutNamespace { return oc.Run(action).Args(parameters...).Output() } return "", nil }
networking
function
openshift/openshift-tests-private
fa65cb32-a9c2-4c7f-86d2-fc7c918b6d32
applyResourceFromTemplateByAdmin
['"encoding/json"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func applyResourceFromTemplateByAdmin(oc *exutil.CLI, parameters ...string) error { var configFile string err := wait.Poll(3*time.Second, 15*time.Second, func() (bool, error) { output, err := oc.AsAdmin().Run("process").Args(parameters...).OutputToFile(getRandomString() + "resource.json") if err != nil { e2e.Logf("the err:%v, and try next round", err) return false, nil } configFile = output return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("as admin fail to process %v", parameters)) e2e.Logf("the file of resource is %s", configFile) return oc.WithoutNamespace().AsAdmin().Run("apply").Args("-f", configFile).Execute() }
networking
function
openshift/openshift-tests-private
073689cc-31a8-4559-a302-64456f180e9a
getRandomString
['"math/rand"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getRandomString() string { chars := "abcdefghijklmnopqrstuvwxyz0123456789" seed := rand.New(rand.NewSource(time.Now().UnixNano())) buffer := make([]byte, 8) for index := range buffer { buffer[index] = chars[seed.Intn(len(chars))] } return string(buffer) }
networking
function
openshift/openshift-tests-private
f6c14d06-7304-4fe5-b83f-ffe0e61f85da
getPodStatus
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodStatus(oc *exutil.CLI, namespace string, podName string) (string, error) { podStatus, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.phase}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s status in namespace %s is %q", podName, namespace, podStatus) return podStatus, err }
networking
function
openshift/openshift-tests-private
b8561039-7b9b-4fe3-af66-cd8058b2c6da
checkPodReady
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkPodReady(oc *exutil.CLI, namespace string, podName string) (bool, error) { podOutPut, err := getPodStatus(oc, namespace, podName) status := []string{"Running", "Ready", "Complete", "Succeeded"} return contains(status, podOutPut), err }
networking
function
openshift/openshift-tests-private
11170da4-5e41-4188-8c60-512dd09b0341
contains
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func contains(s []string, str string) bool { for _, v := range s { if v == str { return true } } return false }
networking
function
openshift/openshift-tests-private
cf0b6245-f081-435d-87b4-3e4edbb0ae13
waitPodReady
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func waitPodReady(oc *exutil.CLI, namespace string, podName string) { err := wait.Poll(10*time.Second, 100*time.Second, func() (bool, error) { status, err1 := checkPodReady(oc, namespace, podName) if err1 != nil { e2e.Logf("the err:%v, wait for pod %v to become ready.", err1, podName) return status, err1 } if !status { return status, nil } return status, nil }) if err != nil { podDescribe := describePod(oc, namespace, podName) e2e.Logf("oc describe pod %v.", podName) e2e.Logf(podDescribe) } exutil.AssertWaitPollNoErr(err, fmt.Sprintf("pod %v is not ready", podName)) }
networking
function
openshift/openshift-tests-private
221b560b-86db-46d3-8193-426544166ff7
describePod
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func describePod(oc *exutil.CLI, namespace string, podName string) string { podDescribe, err := oc.WithoutNamespace().Run("describe").Args("pod", "-n", namespace, podName).Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s status is %q", podName, podDescribe) return podDescribe }
networking
function
openshift/openshift-tests-private
0e65d701-2c83-4a64-b053-131a2c3e047c
execCommandInSpecificPod
['"os/exec"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func execCommandInSpecificPod(oc *exutil.CLI, namespace string, podName string, command string) (string, error) { e2e.Logf("The command is: %v", command) command1 := []string{"-n", namespace, podName, "--", "bash", "-c", command} msg, err := oc.AsAdmin().WithoutNamespace().Run("exec").Args(command1...).Output() if err != nil { e2e.Logf("Execute command failed with err:%v and output is %v.", err, msg) return msg, err } o.Expect(err).NotTo(o.HaveOccurred()) return msg, nil }
networking
function
openshift/openshift-tests-private
0315028f-a010-43ae-9a67-9e6ba7eb6082
execCommandInNetworkingPod
['"os/exec"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func execCommandInNetworkingPod(oc *exutil.CLI, command string) (string, error) { var cmd []string podName, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", "openshift-ovn-kubernetes", "-l", "app=ovnkube-node", "-o=jsonpath={.items[0].metadata.name}").Output() if err != nil { e2e.Logf("Cannot get ovn-kubernetes pods, errors: %v", err) return "", err } cmd = []string{"-n", "openshift-ovn-kubernetes", "-c", "ovnkube-controller", podName, "--", "/bin/sh", "-c", command} msg, err := oc.WithoutNamespace().AsAdmin().Run("exec").Args(cmd...).Output() if err != nil { e2e.Logf("Execute command failed with err:%v .", err) return "", err } o.Expect(err).NotTo(o.HaveOccurred()) return msg, nil }
networking
function
openshift/openshift-tests-private
c3ceeb63-ca15-4f4a-bf9c-9b8dd1dbf479
getDefaultInterface
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getDefaultInterface(oc *exutil.CLI) (string, error) { getDefaultInterfaceCmd := "/usr/sbin/ip -4 route show default" int1, err := execCommandInNetworkingPod(oc, getDefaultInterfaceCmd) if err != nil { e2e.Logf("Cannot get default interface, errors: %v", err) return "", err } defInterface := strings.Split(int1, " ")[4] e2e.Logf("Get the default inteface: %s", defInterface) return defInterface, nil }
networking
function
openshift/openshift-tests-private
e7be0484-5172-473a-91ed-888c8eb81684
getDefaultSubnet
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getDefaultSubnet(oc *exutil.CLI) (string, error) { int1, _ := getDefaultInterface(oc) getDefaultSubnetCmd := "/usr/sbin/ip -4 -brief a show " + int1 subnet1, err := execCommandInNetworkingPod(oc, getDefaultSubnetCmd) defSubnet := strings.Fields(subnet1)[2] if err != nil { e2e.Logf("Cannot get default subnet, errors: %v", err) return "", err } e2e.Logf("Get the default subnet: %s", defSubnet) return defSubnet, nil }
networking
function
openshift/openshift-tests-private
fc001ac5-a419-4c40-ae3c-fd7921e84089
Hosts
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func Hosts(cidr string) ([]string, error) { ip, ipnet, err := net.ParseCIDR(cidr) e2e.Logf("in Hosts function, ip: %v, ipnet: %v", ip, ipnet) if err != nil { return nil, err } var ips []string for ip := ip.Mask(ipnet.Mask); ipnet.Contains(ip); inc(ip) { ips = append(ips, ip.String()) } // remove network address and broadcast address return ips[1 : len(ips)-1], nil }
networking
function
openshift/openshift-tests-private
f98eef65-38d6-4a17-8f23-bab09bc8f247
inc
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func inc(ip net.IP) { for j := len(ip) - 1; j >= 0; j-- { ip[j]++ if ip[j] > 0 { break } } }
networking
function
openshift/openshift-tests-private
fb2c724f-c822-48b2-8905-83a814544382
findUnUsedIPs
['"math/rand"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func findUnUsedIPs(oc *exutil.CLI, cidr string, number int) []string { ipRange, _ := Hosts(cidr) var ipUnused = []string{} //shuffle the ips slice rand.Seed(time.Now().UnixNano()) rand.Shuffle(len(ipRange), func(i, j int) { ipRange[i], ipRange[j] = ipRange[j], ipRange[i] }) for _, ip := range ipRange { if len(ipUnused) < number { pingCmd := "ping -c4 -t1 " + ip _, err := execCommandInNetworkingPod(oc, pingCmd) if err != nil { e2e.Logf("%s is not used!\n", ip) ipUnused = append(ipUnused, ip) } } else { break } } return ipUnused }
networking
function
openshift/openshift-tests-private
3aea06d9-087e-4b04-a789-0b8abb549fdf
ipEchoServer
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func ipEchoServer() string { return "172.31.249.80:9095" }
networking
function
openshift/openshift-tests-private
cfe6986b-5a8c-4984-9bbd-06e9bf316b71
checkPlatform
['"strings"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkPlatform(oc *exutil.CLI) string { output, _ := oc.WithoutNamespace().AsAdmin().Run("get").Args("infrastructure", "cluster", "-o=jsonpath={.status.platformStatus.type}").Output() return strings.ToLower(output) }
networking
function
openshift/openshift-tests-private
650007b6-54e7-4d79-b5bc-e1f742c3ab67
checkNetworkType
['"strings"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkNetworkType(oc *exutil.CLI) string { output, _ := oc.WithoutNamespace().AsAdmin().Run("get").Args("network.operator", "cluster", "-o=jsonpath={.spec.defaultNetwork.type}").Output() return strings.ToLower(output) }
networking
function
openshift/openshift-tests-private
be22b708-de6a-41a9-a736-7cd37351c3d8
getDefaultIPv6Subnet
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getDefaultIPv6Subnet(oc *exutil.CLI) (string, error) { int1, _ := getDefaultInterface(oc) getDefaultSubnetCmd := "/usr/sbin/ip -6 -brief a show " + int1 subnet1, err := execCommandInNetworkingPod(oc, getDefaultSubnetCmd) if err != nil { e2e.Logf("Cannot get default ipv6 subnet, errors: %v", err) return "", err } defSubnet := strings.Fields(subnet1)[2] e2e.Logf("Get the default ipv6 subnet: %s", defSubnet) return defSubnet, nil }
networking
function
openshift/openshift-tests-private
d1b8c682-6abc-42d3-babc-0c636766a28c
findUnUsedIPv6
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func findUnUsedIPv6(oc *exutil.CLI, cidr string, number int) ([]string, error) { ip, ipnet, err := net.ParseCIDR(cidr) if err != nil { return nil, err } number += 2 var ips []string var i = 0 for ip := ip.Mask(ipnet.Mask); ipnet.Contains(ip); inc(ip) { //Not use the first two IPv6 addresses , such as 2620:52:0:4e:: , 2620:52:0:4e::1 if i == 0 || i == 1 { i++ continue } //Start to detect the IPv6 adress is used or not if i < number { pingCmd := "ping -c4 -t1 -6 " + ip.String() _, err := execCommandInNetworkingPod(oc, pingCmd) if err != nil { e2e.Logf("%s is not used!\n", ip) ips = append(ips, ip.String()) i++ } } else { break } } return ips, nil }
networking
function
openshift/openshift-tests-private
3160c587-8fe7-41c1-b051-006006092de0
ipv6EchoServer
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func ipv6EchoServer(isIPv6 bool) string { if isIPv6 { return "[2620:52:0:4974:def4:1ff:fee7:8144]:8085" } return "10.73.116.56:8085" }
networking
function
openshift/openshift-tests-private
270928a3-4ada-4514-93ab-81b23fc4b1aa
checkIPStackType
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkIPStackType(oc *exutil.CLI) string { svcNetwork, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("network.operator", "cluster", "-o=jsonpath={.spec.serviceNetwork}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if strings.Count(svcNetwork, ":") >= 2 && strings.Count(svcNetwork, ".") >= 2 { return "dualstack" } else if strings.Count(svcNetwork, ":") >= 2 { return "ipv6single" } else if strings.Count(svcNetwork, ".") >= 2 { return "ipv4single" } return "" }
networking
function
openshift/openshift-tests-private
90aee14e-29a2-45ad-87e0-bb7ed5da9860
installSctpModule
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func installSctpModule(oc *exutil.CLI, configFile string) { status, _ := oc.AsAdmin().Run("get").Args("machineconfigs").Output() if !strings.Contains(status, "load-sctp-module") { err := oc.WithoutNamespace().AsAdmin().Run("create").Args("-f", configFile).Execute() o.Expect(err).NotTo(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
56757102-3fb0-4b5d-93ee-14363f571511
checkSctpModule
['"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkSctpModule(oc *exutil.CLI, nodeName, namespace string) { defer exutil.RecoverNamespaceRestricted(oc, namespace) exutil.SetNamespacePrivileged(oc, namespace) err := wait.Poll(30*time.Second, 15*time.Minute, func() (bool, error) { // Check nodes status to make sure all nodes are up after rebooting caused by load-sctp-module nodesStatus, err := oc.AsAdmin().Run("get").Args("node").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("oc_get_nodes: %v", nodesStatus) status, _ := oc.AsAdmin().Run("debug").Args("node/"+nodeName, "--", "cat", "/sys/module/sctp/initstate").Output() if strings.Contains(status, "live") { e2e.Logf("stcp module is installed in the %s", nodeName) return true, nil } return false, nil }) exutil.AssertWaitPollNoErr(err, "stcp module is installed in the nodes") }
networking
function
openshift/openshift-tests-private
01847a8c-885d-4ad0-8269-7c6601584864
getPodIPv4
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodIPv4(oc *exutil.CLI, namespace string, podName string) string { podIPv4, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[0].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s IP in namespace %s is %q", podName, namespace, podIPv4) return podIPv4 }
networking
function
openshift/openshift-tests-private
43971105-8897-4f31-8f41-7130aec7006b
getPodIPv6
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodIPv6(oc *exutil.CLI, namespace string, podName string, ipStack string) string { if ipStack == "ipv6single" { podIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[0].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s IP in namespace %s is %q", podName, namespace, podIPv6) return podIPv6 } else if ipStack == "dualstack" { podIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[1].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s IP in namespace %s is %q", podName, namespace, podIPv6) return podIPv6 } return "" }
networking
function
openshift/openshift-tests-private
13749905-7874-4c59-9cd5-2c08c9c52ba2
createResourceFromFile
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func createResourceFromFile(oc *exutil.CLI, ns, file string) { err := oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", file, "-n", ns).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
5c4db15e-8d83-45e5-91f1-8fb8bb72bf04
waitForPodWithLabelReady
['"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func waitForPodWithLabelReady(oc *exutil.CLI, ns, label string) error { return wait.Poll(5*time.Second, 5*time.Minute, func() (bool, error) { status, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", ns, "-l", label, "-ojsonpath={.items[*].status.conditions[?(@.type==\"Ready\")].status}").Output() e2e.Logf("the Ready status of pod is %v", status) if err != nil || status == "" { e2e.Logf("failed to get pod status: %v, retrying...", err) return false, nil } if strings.Contains(status, "False") { e2e.Logf("the pod Ready status not met; wanted True but got %v, retrying...", status) return false, nil } return true, nil }) }
networking
function
openshift/openshift-tests-private
fe127e06-8b84-43a8-b647-35d3caeae3cf
waitForPodWithLabelGone
['"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func waitForPodWithLabelGone(oc *exutil.CLI, ns, label string) error { errWait := wait.Poll(5*time.Second, 10*time.Minute, func() (bool, error) { podsOutput, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", ns, "-l", label).Output() if strings.Contains(podsOutput, "NotFound") || strings.Contains(podsOutput, "No resources found") { e2e.Logf("the resource is deleted already") return true, nil } e2e.Logf("Wait for pods to be deleted, retrying...") return false, nil }) if errWait != nil { return fmt.Errorf("case: %v\nerror: %s", g.CurrentSpecReport().FullText(), fmt.Sprintf("pod with lable %v in ns %v is not gone", label, ns)) } return nil }
networking
function
openshift/openshift-tests-private
1bb37ae3-2e3d-419a-9cdc-bd35d0e71721
getSvcIPv4
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSvcIPv4(oc *exutil.CLI, namespace string, svcName string) string { svcIPv4, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IPv4 in namespace %s is %q", svcName, namespace, svcIPv4) return svcIPv4 }
networking
function
openshift/openshift-tests-private
762e2dc5-b340-4161-83ae-f4cbc23e782e
getSvcIPv6
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSvcIPv6(oc *exutil.CLI, namespace string, svcName string) string { svcIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[1]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IPv6 in namespace %s is %q", svcName, namespace, svcIPv6) return svcIPv6 }
networking
function
openshift/openshift-tests-private
684b9573-21c0-48ca-9e11-889f617afd97
getSvcIPv6SingleStack
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSvcIPv6SingleStack(oc *exutil.CLI, namespace string, svcName string) string { svcIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IPv6 in namespace %s is %q", svcName, namespace, svcIPv6) return svcIPv6 }
networking
function
openshift/openshift-tests-private
138d2b1b-271a-4235-95be-22723bed88c9
getSvcIPdualstack
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSvcIPdualstack(oc *exutil.CLI, namespace string, svcName string) (string, string) { svcIPv4, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IPv4 in namespace %s is %q", svcName, namespace, svcIPv4) svcIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[1]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IPv6 in namespace %s is %q", svcName, namespace, svcIPv6) return svcIPv4, svcIPv6 }
networking
function
openshift/openshift-tests-private
1bf727af-7c9e-4adc-af77-6f829452b5c9
checkConfigMap
['"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkConfigMap(oc *exutil.CLI, ns, configmapName string) error { return wait.Poll(5*time.Second, 3*time.Minute, func() (bool, error) { searchOutput, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("cm", "-n", ns).Output() if err != nil { e2e.Logf("failed to get configmap: %v", err) return false, nil } if o.Expect(searchOutput).To(o.ContainSubstring(configmapName)) { e2e.Logf("configmap %v found", configmapName) return true, nil } return false, nil }) }
networking
function
openshift/openshift-tests-private
d7952ebe-26b7-40fc-a01a-d7811d7f593f
sshRunCmd
['"os"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func sshRunCmd(host string, user string, cmd string) error { privateKey := os.Getenv("SSH_CLOUD_PRIV_KEY") if privateKey == "" { privateKey = "../internal/config/keys/openshift-qe.pem" } sshClient := exutil.SshClient{User: user, Host: host, Port: 22, PrivateKey: privateKey} return sshClient.Run(cmd) }
networking
function
openshift/openshift-tests-private
34b48aaf-244e-4ef0-a859-8fa2c6cbb395
patchResourceAsAdmin
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func patchResourceAsAdmin(oc *exutil.CLI, resource, patch string, nameSpace ...string) { var cargs []string if len(nameSpace) > 0 { cargs = []string{resource, "-p", patch, "-n", nameSpace[0], "--type=merge"} } else { cargs = []string{resource, "-p", patch, "--type=merge"} } err := oc.AsAdmin().WithoutNamespace().Run("patch").Args(cargs...).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
785bad32-e768-41cd-a55a-3346baa3bf9f
checkNetworkOperatorState
['"regexp"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkNetworkOperatorState(oc *exutil.CLI, interval int, timeout int) { errCheck := wait.Poll(time.Duration(interval)*time.Second, time.Duration(timeout)*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "network").Output() if err != nil { e2e.Logf("Fail to get clusteroperator network, error:%s. Trying again", err) return false, nil } matched, _ := regexp.MatchString("True.*False.*False", output) e2e.Logf("Network operator state is:%s", output) o.Expect(matched).To(o.BeTrue()) return false, nil }) o.Expect(errCheck.Error()).To(o.ContainSubstring("timed out waiting for the condition")) }
networking
function
openshift/openshift-tests-private
fedb46d2-4855-4400-8880-18fc2f77fe2d
getNodeIPv4
['"regexp"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getNodeIPv4(oc *exutil.CLI, namespace, nodeName string) string { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", oc.Namespace(), "node", nodeName, "-o=jsonpath={.status.addresses[?(@.type==\"InternalIP\")].address}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if err != nil { e2e.Logf("Cannot get node default interface ipv4 address, errors: %v", err) } // when egressIP is applied to a node, it would be listed as internal IP for the node, thus, there could be more than one IPs shown as internal IP // use RE to match out to first internal IP re := regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`) nodeipv4 := re.FindAllString(output, -1)[0] e2e.Logf("The IPv4 of node's default interface is %q", nodeipv4) return nodeipv4 }
networking
function
openshift/openshift-tests-private
dc467cd4-8c3e-4d26-a4bf-a7d4fc7a3c9c
getNodeIP
['e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getNodeIP(oc *exutil.CLI, nodeName string) (string, string) { ipStack := checkIPStackType(oc) if (ipStack == "ipv6single") || (ipStack == "ipv4single") { e2e.Logf("Its a Single Stack Cluster, either IPv4 or IPv6") InternalIP, err := oc.AsAdmin().Run("get").Args("node", nodeName, "-o=jsonpath={.status.addresses[?(@.type==\"InternalIP\")].address}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The node's Internal IP is %q", InternalIP) return "", InternalIP } e2e.Logf("Its a Dual Stack Cluster") InternalIP1, err := oc.AsAdmin().Run("get").Args("node", nodeName, "-o=jsonpath={.status.addresses[0].address}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The node's 1st Internal IP is %q", InternalIP1) InternalIP2, err := oc.AsAdmin().Run("get").Args("node", nodeName, "-o=jsonpath={.status.addresses[1].address}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The node's 2nd Internal IP is %q", InternalIP2) if netutils.IsIPv6String(InternalIP1) { return InternalIP1, InternalIP2 } return InternalIP2, InternalIP1 }
networking
function
openshift/openshift-tests-private
d6461f85-1629-47b5-a2a4-e4c5b98e71ab
getLeaderInfo
['"encoding/json"', '"io"', '"os"', '"os/exec"', '"strings"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getLeaderInfo(oc *exutil.CLI, namespace string, cmName string, networkType string) string { if networkType == "ovnkubernetes" { linuxNodeList, err := exutil.GetAllNodesbyOSType(oc, "linux") o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(linuxNodeList).NotTo(o.BeEmpty()) podName, getPodNameErr := exutil.GetPodName(oc, namespace, cmName, linuxNodeList[0]) o.Expect(getPodNameErr).NotTo(o.HaveOccurred()) o.Expect(podName).NotTo(o.BeEmpty()) return podName } output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("cm", "openshift-network-controller", "-n", namespace, "-o=jsonpath={.metadata.annotations.control-plane\\.alpha\\.kubernetes\\.io\\/leader}").Output() o.Expect(err).NotTo(o.HaveOccurred()) var sdnAnnotations map[string]interface{} json.Unmarshal([]byte(output), &sdnAnnotations) leaderNodeName := sdnAnnotations["holderIdentity"].(string) o.Expect(leaderNodeName).NotTo(o.BeEmpty()) ocGetPods, podErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", "openshift-sdn", "pod", "-l app=sdn", "-o=wide").OutputToFile("ocgetpods.txt") defer os.RemoveAll(ocGetPods) o.Expect(podErr).NotTo(o.HaveOccurred()) rawGrepOutput, rawGrepErr := exec.Command("bash", "-c", "cat "+ocGetPods+" | grep "+leaderNodeName+" | awk '{print $1}'").Output() o.Expect(rawGrepErr).NotTo(o.HaveOccurred()) leaderPodName := strings.TrimSpace(string(rawGrepOutput)) e2e.Logf("The leader Pod's name: %v", leaderPodName) return leaderPodName }
networking
function
openshift/openshift-tests-private
1ae21060-ac8a-4cba-8dce-1139f7202acd
checkSDNMetrics
['"fmt"', '"os/exec"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkSDNMetrics(oc *exutil.CLI, url string, metrics string) { var metricsOutput []byte var metricsLog []byte olmToken, err := exutil.GetSAToken(oc) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmToken).NotTo(o.BeEmpty()) metricsErr := wait.Poll(5*time.Second, 10*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("exec").Args("-n", "openshift-monitoring", "-c", "prometheus", "prometheus-k8s-0", "--", "curl", "-k", "-H", fmt.Sprintf("Authorization: Bearer %v", olmToken), fmt.Sprintf("%s", url)).OutputToFile("metrics.txt") if err != nil { e2e.Logf("Can't get metrics and try again, the error is:%s", err) return false, nil } metricsLog, _ = exec.Command("bash", "-c", "cat "+output+" ").Output() metricsString := string(metricsLog) if strings.Contains(metricsString, "ovnkube_controller_pod") { metricsOutput, _ = exec.Command("bash", "-c", "cat "+output+" | grep "+metrics+" | awk 'NR==1{print $2}'").Output() } else { metricsOutput, _ = exec.Command("bash", "-c", "cat "+output+" | grep "+metrics+" | awk 'NR==3{print $2}'").Output() } metricsValue := strings.TrimSpace(string(metricsOutput)) if metricsValue != "" { e2e.Logf("The output of the metrics for %s is : %v", metrics, metricsValue) } else { e2e.Logf("Can't get metrics for %s:", metrics) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(metricsErr, fmt.Sprintf("Fail to get metric and the error is:%s", metricsErr)) }
networking
function
openshift/openshift-tests-private
8e763a7b-4d22-4cba-b1da-5ce7aae2208e
getEgressCIDRs
['e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getEgressCIDRs(oc *exutil.CLI, node string) string { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("hostsubnet", node, "-o=jsonpath={.egressCIDRs}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("egressCIDR for hostsubnet node %v is: %v", node, output) return output }
networking
function
openshift/openshift-tests-private
0f002c83-9857-46f6-95df-19d758d27eac
getEgressIPByKind
['"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getEgressIPByKind(oc *exutil.CLI, kind string, kindName string, expectedNum int) ([]string, error) { var ip = []string{} iplist, err := oc.AsAdmin().WithoutNamespace().Run("get").Args(kind, kindName, "-o=jsonpath={.egressIPs}").Output() isIPListEmpty := (iplist == "" || iplist == "[]") if expectedNum == 0 { // Add waiting time for egressIP removed egressIPEmptyErr := wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { iplist, err = oc.AsAdmin().WithoutNamespace().Run("get").Args(kind, kindName, "-o=jsonpath={.egressIPs}").Output() if iplist == "" || iplist == "[]" { e2e.Logf("EgressIP list is empty") return true, nil } e2e.Logf("EgressIP list is %s, not removed, or have err:%v, and try next round", iplist, err) return false, nil }) return ip, egressIPEmptyErr } if !isIPListEmpty && iplist != "[]" { ip = strings.Split(iplist[2:len(iplist)-2], "\",\"") } if isIPListEmpty || len(ip) < expectedNum || err != nil { err = wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) { iplist, err = oc.AsAdmin().WithoutNamespace().Run("get").Args(kind, kindName, "-o=jsonpath={.egressIPs}").Output() if len(iplist) > 0 && iplist != "[]" { ip = strings.Split(iplist[2:len(iplist)-2], "\",\"") } if len(ip) < expectedNum || err != nil { e2e.Logf("only got %d egressIP, or have err:%v, and try next round", len(ip), err) return false, nil } if len(iplist) > 0 && len(ip) == expectedNum { e2e.Logf("Found egressIP list for %v %v is: %v", kind, kindName, iplist) return true, nil } return false, nil }) e2e.Logf("Only got %d egressIP, or have err:%v", len(ip), err) return ip, err } return ip, nil }
networking
function
openshift/openshift-tests-private
42085edd-9f7f-4bc9-baab-48c0da74316d
getPodName
['"strings"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodName(oc *exutil.CLI, namespace string, label string) []string { var podName []string podNameAll, err := oc.AsAdmin().Run("get").Args("-n", namespace, "pod", "-l", label, "-ojsonpath={.items..metadata.name}").Output() o.Expect(err).NotTo(o.HaveOccurred()) podName = strings.Split(podNameAll, " ") e2e.Logf("The pod(s) are %v ", podName) return podName }
networking
function
openshift/openshift-tests-private
6ae7c1a7-863f-44cb-99f6-ac3309c9bac0
findTwoNodesWithSameSubnet
['v1 "k8s.io/api/core/v1"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func findTwoNodesWithSameSubnet(oc *exutil.CLI, nodeList *v1.NodeList) (bool, [2]string) { var nodes [2]string for i := 0; i < (len(nodeList.Items) - 1); i++ { for j := i + 1; j < len(nodeList.Items); j++ { firstSub := getIfaddrFromNode(nodeList.Items[i].Name, oc) secondSub := getIfaddrFromNode(nodeList.Items[j].Name, oc) if firstSub == secondSub { e2e.Logf("Found nodes with same subnet.") nodes[0] = nodeList.Items[i].Name nodes[1] = nodeList.Items[j].Name return true, nodes } } } return false, nodes }
networking
function
openshift/openshift-tests-private
9069672a-64a0-4339-9fe4-49d534de0d72
getSDNMetrics
['"fmt"', '"os/exec"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSDNMetrics(oc *exutil.CLI, podName string) string { var metricsLog string metricsErr := wait.Poll(5*time.Second, 10*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("exec").Args("-n", "openshift-sdn", fmt.Sprintf("%s", podName), "--", "curl", "localhost:29100/metrics").OutputToFile("metrics.txt") if err != nil { e2e.Logf("Can't get metrics and try again, the error is:%s", err) return false, nil } metricsLog = output return true, nil }) exutil.AssertWaitPollNoErr(metricsErr, fmt.Sprintf("Fail to get metric and the error is:%s", metricsErr)) return metricsLog }
networking
function
openshift/openshift-tests-private
833659e0-ddfd-4eba-8427-e7a37c584d8c
getOVNMetrics
['"fmt"', '"os/exec"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getOVNMetrics(oc *exutil.CLI, url string) string { var metricsLog string olmToken, err := exutil.GetSAToken(oc) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmToken).NotTo(o.BeEmpty()) metricsErr := wait.Poll(5*time.Second, 10*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("exec").Args("-n", "openshift-monitoring", "-c", "prometheus", "prometheus-k8s-0", "--", "curl", "-k", "-H", fmt.Sprintf("Authorization: Bearer %v", olmToken), fmt.Sprintf("%s", url)).OutputToFile("metrics.txt") if err != nil { e2e.Logf("Can't get metrics and try again, the error is:%s", err) return false, nil } metricsLog = output return true, nil }) exutil.AssertWaitPollNoErr(metricsErr, fmt.Sprintf("Fail to get metric and the error is:%s", metricsErr)) return metricsLog }
networking
function
openshift/openshift-tests-private
4679e8ba-c4e7-4e9a-ba13-86b7d9b00afd
checkIPsec
['e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkIPsec(oc *exutil.CLI) string { output, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("network.operator", "cluster", "-o=jsonpath={.spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig.mode}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if output == "" { // if have {} in 4.15+, that means it upgraded from previous version and with ipsec enabled. output, err = oc.WithoutNamespace().AsAdmin().Run("get").Args("network.operator", "cluster", "-o=jsonpath={.spec.defaultNetwork.ovnKubernetesConfig.ipsecConfig}").Output() o.Expect(err).NotTo(o.HaveOccurred()) } e2e.Logf("The ipsec state is === %v ===", output) return output }
networking
function
openshift/openshift-tests-private
b934f103-3d0e-43ed-91c4-2b59f03b7128
getAssignedEIPInEIPObject
['"encoding/json"', '"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getAssignedEIPInEIPObject(oc *exutil.CLI, egressIPObject string) []map[string]string { timeout := estimateTimeoutForEgressIP(oc) var egressIPs string egressipErr := wait.Poll(10*time.Second, timeout, func() (bool, error) { egressIPStatus, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("egressip", egressIPObject, "-ojsonpath={.status.items}").Output() if err != nil { e2e.Logf("Wait to get EgressIP object applied,try next round. %v", err) return false, nil } if egressIPStatus == "" { e2e.Logf("Wait to get EgressIP object applied,try next round. %v", err) return false, nil } egressIPs = egressIPStatus e2e.Logf("egressIPStatus: %v", egressIPs) return true, nil }) exutil.AssertWaitPollNoErr(egressipErr, fmt.Sprintf("Failed to apply egressIPs:%s", egressipErr)) var egressIPJsonMap []map[string]string json.Unmarshal([]byte(egressIPs), &egressIPJsonMap) e2e.Logf("egressIPJsonMap:%v", egressIPJsonMap) return egressIPJsonMap }
networking
function
openshift/openshift-tests-private
9f977f42-18a2-4d75-bfee-8e04f9f25695
rebootNode
['e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func rebootNode(oc *exutil.CLI, nodeName string) { e2e.Logf("\nRebooting node %s....", nodeName) _, err1 := exutil.DebugNodeWithChroot(oc, nodeName, "shutdown", "-r", "+1") o.Expect(err1).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
eb0cd537-639f-402d-a6b9-5141ee33dbcd
checkNodeStatus
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkNodeStatus(oc *exutil.CLI, nodeName string, expectedStatus string) { var expectedStatus1 string if expectedStatus == "Ready" { expectedStatus1 = "True" } else if expectedStatus == "NotReady" { expectedStatus1 = "Unknown" } else { err1 := fmt.Errorf("TBD supported node status") o.Expect(err1).NotTo(o.HaveOccurred()) } err := wait.Poll(5*time.Second, 15*time.Minute, func() (bool, error) { statusOutput, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", nodeName, "-ojsonpath={.status.conditions[-1].status}").Output() if err != nil { e2e.Logf("\nGet node status with error : %v", err) return false, nil } e2e.Logf("Expect Node %s in state %v, kubelet status is %s", nodeName, expectedStatus, statusOutput) if statusOutput != expectedStatus1 { return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Node %s is not in expected status %s", nodeName, expectedStatus)) }
networking
function
openshift/openshift-tests-private
262aae47-5e75-4e6d-a374-8817dd04d46d
updateEgressIPObject
['"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func updateEgressIPObject(oc *exutil.CLI, egressIPObjectName string, egressIP string) { patchResourceAsAdmin(oc, "egressip/"+egressIPObjectName, "{\"spec\":{\"egressIPs\":[\""+egressIP+"\"]}}") egressipErr := wait.Poll(10*time.Second, 180*time.Second, func() (bool, error) { output, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("egressip", egressIPObjectName, "-o=jsonpath={.status.items[*]}").Output() if err != nil { e2e.Logf("Wait to get EgressIP object applied,try next round. %v", err) return false, nil } if !strings.Contains(output, egressIP) { e2e.Logf("Wait for new IP %s applied,try next round.", egressIP) e2e.Logf(output) return false, nil } e2e.Logf(output) return true, nil }) exutil.AssertWaitPollNoErr(egressipErr, fmt.Sprintf("Failed to apply new egressIP %s:%v", egressIP, egressipErr)) }
networking
function
openshift/openshift-tests-private
77f49b9b-23eb-4f1b-9b08-6b40a0078a02
getTwoNodesSameSubnet
['"strings"', 'v1 "k8s.io/api/core/v1"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getTwoNodesSameSubnet(oc *exutil.CLI, nodeList *v1.NodeList) (bool, []string) { var egressNodes []string if len(nodeList.Items) < 2 { e2e.Logf("Not enough nodes available for the test, skip the case!!") return false, nil } platform := exutil.CheckPlatform(oc) if strings.Contains(platform, "aws") { e2e.Logf("find the two nodes that have same subnet") check, nodes := findTwoNodesWithSameSubnet(oc, nodeList) if check { egressNodes = nodes[:2] } else { e2e.Logf("No more than 2 worker nodes in same subnet, skip the test!!!") return false, nil } } else { e2e.Logf("since worker nodes all have same subnet, just pick first two nodes as egress nodes") egressNodes = append(egressNodes, nodeList.Items[0].Name) egressNodes = append(egressNodes, nodeList.Items[1].Name) } return true, egressNodes }
networking
function
openshift/openshift-tests-private
4c427c01-a4f7-4f5a-80a3-2cdb776cecfb
getSvcIP
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getSvcIP(oc *exutil.CLI, namespace string, svcName string) (string, string) { ipStack := checkIPStackType(oc) svctype, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.type}").Output() o.Expect(err).NotTo(o.HaveOccurred()) ipFamilyType, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.ipFamilyPolicy}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if (svctype == "ClusterIP") || (svctype == "NodePort") { if (ipStack == "ipv6single") || (ipStack == "ipv4single") { svcIP, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) if svctype == "ClusterIP" { e2e.Logf("The service %s IP in namespace %s is %q", svcName, namespace, svcIP) return svcIP, "" } nodePort, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.ports[*].nodePort}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The NodePort service %s IP and NodePort in namespace %s is %s %s", svcName, namespace, svcIP, nodePort) return svcIP, nodePort } else if (ipStack == "dualstack" && ipFamilyType == "PreferDualStack") || (ipStack == "dualstack" && ipFamilyType == "RequireDualStack") { ipFamilyPrecedence, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.ipFamilies[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) //if IPv4 is listed first in ipFamilies then clustrIPs allocation will take order as Ipv4 first and then Ipv6 else reverse svcIPv4, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IP in namespace %s is %q", svcName, namespace, svcIPv4) svcIPv6, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[1]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IP in namespace %s is %q", svcName, namespace, svcIPv6) /*As stated Nodeport type svc will return node port value in 2nd var. We don't care about what svc address is coming in 1st var as we evetually going to get node IPs later and use that in curl operation to node_ip:nodeport*/ if ipFamilyPrecedence == "IPv4" { e2e.Logf("The ipFamilyPrecedence is Ipv4, Ipv6") switch svctype { case "NodePort": nodePort, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.ports[*].nodePort}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The Dual Stack NodePort service %s IP and NodePort in namespace %s is %s %s", svcName, namespace, svcIPv4, nodePort) return svcIPv4, nodePort default: return svcIPv6, svcIPv4 } } else { e2e.Logf("The ipFamilyPrecedence is Ipv6, Ipv4") switch svctype { case "NodePort": nodePort, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.ports[*].nodePort}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The Dual Stack NodePort service %s IP and NodePort in namespace %s is %s %s", svcName, namespace, svcIPv6, nodePort) return svcIPv6, nodePort default: svcIPv4, svcIPv6 = svcIPv6, svcIPv4 return svcIPv6, svcIPv4 } } } else { //Its a Dual Stack Cluster with SingleStack ipFamilyPolicy svcIP, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, "-o=jsonpath={.spec.clusterIPs[0]}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The service %s IP in namespace %s is %q", svcName, namespace, svcIP) return svcIP, "" } } else { //Loadbalancer will be supported for single stack Ipv4 here for mostly GCP,Azure. We can take further enhancements wrt Metal platforms in Metallb utils later e2e.Logf("The serviceType is LoadBalancer") platform := exutil.CheckPlatform(oc) var jsonString string if platform == "aws" { jsonString = "-o=jsonpath={.status.loadBalancer.ingress[0].hostname}" } else { jsonString = "-o=jsonpath={.status.loadBalancer.ingress[0].ip}" } err := wait.Poll(30*time.Second, 300*time.Second, func() (bool, error) { svcIP, er := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, jsonString).Output() o.Expect(er).NotTo(o.HaveOccurred()) if svcIP == "" { e2e.Logf("Waiting for lb service IP assignment. Trying again...") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to assign lb svc IP to %v", svcName)) lbSvcIP, _ := oc.AsAdmin().WithoutNamespace().Run("get").Args("service", "-n", namespace, svcName, jsonString).Output() e2e.Logf("The %s lb service Ingress VIP in namespace %s is %q", svcName, namespace, lbSvcIP) return lbSvcIP, "" } }
networking
function
openshift/openshift-tests-private
ce2e46a3-bd72-440d-8e37-d55a20b2ef5b
getPodIP
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodIP(oc *exutil.CLI, namespace string, podName string) (string, string) { ipStack := checkIPStackType(oc) if (ipStack == "ipv6single") || (ipStack == "ipv4single") { podIP, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[0].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod %s IP in namespace %s is %q", podName, namespace, podIP) return podIP, "" } else if ipStack == "dualstack" { podIP1, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[1].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod's %s 1st IP in namespace %s is %q", podName, namespace, podIP1) podIP2, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", namespace, podName, "-o=jsonpath={.status.podIPs[0].ip}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The pod's %s 2nd IP in namespace %s is %q", podName, namespace, podIP2) if netutils.IsIPv6String(podIP1) { e2e.Logf("This is IPv4 primary dual stack cluster") return podIP1, podIP2 } e2e.Logf("This is IPv6 primary dual stack cluster") return podIP2, podIP1 } return "", "" }
networking
function
openshift/openshift-tests-private
8d2d79f3-89e8-4087-b31f-51919ae291b6
CurlPod2PodPass
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlPod2PodPass(oc *exutil.CLI, namespaceSrc string, podNameSrc string, namespaceDst string, podNameDst string) { podIP1, podIP2 := getPodIP(oc, namespaceDst, podNameDst) if podIP2 != "" { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP1, "8080")) o.Expect(err).NotTo(o.HaveOccurred()) _, err = e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP2, "8080")) o.Expect(err).NotTo(o.HaveOccurred()) } else { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP1, "8080")) o.Expect(err).NotTo(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
edc442ad-6826-4f29-9408-1ea2d6f1840a
CurlPod2PodFail
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlPod2PodFail(oc *exutil.CLI, namespaceSrc string, podNameSrc string, namespaceDst string, podNameDst string) { podIP1, podIP2 := getPodIP(oc, namespaceDst, podNameDst) if podIP2 != "" { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP1, "8080")) o.Expect(err).To(o.HaveOccurred()) _, err = e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP2, "8080")) o.Expect(err).To(o.HaveOccurred()) } else { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(podIP1, "8080")) o.Expect(err).To(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
329f120f-591e-4e4b-96d7-beb0a26bb798
CurlNode2PodPass
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlNode2PodPass(oc *exutil.CLI, nodeName string, namespace string, podName string) { //getPodIP returns IPv6 and IPv4 in order on dual stack in PodIP1 and PodIP2 respectively and main IP in case of single stack (v4 or v6) in PodIP1, and nil in PodIP2 podIP1, podIP2 := getPodIP(oc, namespace, podName) if podIP2 != "" { podv6URL := net.JoinHostPort(podIP1, "8080") podv4URL := net.JoinHostPort(podIP2, "8080") _, err := exutil.DebugNode(oc, nodeName, "curl", podv4URL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) _, err = exutil.DebugNode(oc, nodeName, "curl", podv6URL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) } else { podURL := net.JoinHostPort(podIP1, "8080") _, err := exutil.DebugNode(oc, nodeName, "curl", podURL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
e232482d-d314-4412-8f86-8bfb17a2dae0
CurlNode2SvcPass
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlNode2SvcPass(oc *exutil.CLI, nodeName string, namespace string, svcName string) { svcIP1, svcIP2 := getSvcIP(oc, namespace, svcName) if svcIP2 != "" { svc6URL := net.JoinHostPort(svcIP1, "27017") svc4URL := net.JoinHostPort(svcIP2, "27017") _, err := exutil.DebugNode(oc, nodeName, "curl", svc4URL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) _, err = exutil.DebugNode(oc, nodeName, "curl", svc6URL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) } else { svcURL := net.JoinHostPort(svcIP1, "27017") _, err := exutil.DebugNode(oc, nodeName, "curl", svcURL, "-s", "--connect-timeout", "5") o.Expect(err).NotTo(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
97374e48-386c-4e90-ad5a-67dee8535ca8
CurlNode2SvcFail
['"net"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlNode2SvcFail(oc *exutil.CLI, nodeName string, namespace string, svcName string) { svcIP1, svcIP2 := getSvcIP(oc, namespace, svcName) if svcIP2 != "" { svc6URL := net.JoinHostPort(svcIP1, "27017") svc4URL := net.JoinHostPort(svcIP2, "27017") output, _ := exutil.DebugNode(oc, nodeName, "curl", svc4URL, "--connect-timeout", "5") o.Expect(output).To(o.Or(o.ContainSubstring("28"), o.ContainSubstring("Failed"))) output, _ = exutil.DebugNode(oc, nodeName, "curl", svc6URL, "--connect-timeout", "5") o.Expect(output).To(o.Or(o.ContainSubstring("28"), o.ContainSubstring("Failed"))) } else { svcURL := net.JoinHostPort(svcIP1, "27017") output, _ := exutil.DebugNode(oc, nodeName, "curl", svcURL, "--connect-timeout", "5") o.Expect(output).To(o.Or(o.ContainSubstring("28"), o.ContainSubstring("Failed"))) } }
networking
function
openshift/openshift-tests-private
8808b2d9-2beb-47b7-9edb-14f134dfd574
CurlPod2SvcPass
['"net"', '"time"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlPod2SvcPass(oc *exutil.CLI, namespaceSrc string, namespaceSvc string, podNameSrc string, svcName string) { svcIP1, svcIP2 := getSvcIP(oc, namespaceSvc, svcName) if svcIP2 != "" { _, err := e2eoutput.RunHostCmdWithRetries(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP1, "27017"), 3*time.Second, 15*time.Second) o.Expect(err).NotTo(o.HaveOccurred()) _, err = e2eoutput.RunHostCmdWithRetries(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP2, "27017"), 3*time.Second, 15*time.Second) o.Expect(err).NotTo(o.HaveOccurred()) } else { _, err := e2eoutput.RunHostCmdWithRetries(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP1, "27017"), 3*time.Second, 15*time.Second) o.Expect(err).NotTo(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
deb9f27d-20c7-4ef6-a5f3-1716c4db0643
CurlPod2SvcFail
['"net"', 'netutils "k8s.io/utils/net"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func CurlPod2SvcFail(oc *exutil.CLI, namespaceSrc string, namespaceSvc string, podNameSrc string, svcName string) { svcIP1, svcIP2 := getSvcIP(oc, namespaceSvc, svcName) if svcIP2 != "" { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP1, "27017")) o.Expect(err).To(o.HaveOccurred()) _, err = e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP2, "27017")) o.Expect(err).To(o.HaveOccurred()) } else { _, err := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl --connect-timeout 5 -s "+net.JoinHostPort(svcIP1, "27017")) o.Expect(err).To(o.HaveOccurred()) } }
networking
function
openshift/openshift-tests-private
9f31c7e9-1b7d-40e5-9982-bc8589e4ac4c
checkProxy
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkProxy(oc *exutil.CLI) bool { httpProxy, err := doAction(oc, "get", true, true, "proxy", "cluster", "-o=jsonpath={.status.httpProxy}") o.Expect(err).NotTo(o.HaveOccurred()) httpsProxy, err := doAction(oc, "get", true, true, "proxy", "cluster", "-o=jsonpath={.status.httpsProxy}") o.Expect(err).NotTo(o.HaveOccurred()) if httpProxy != "" || httpsProxy != "" { return true } return false }
networking
function
openshift/openshift-tests-private
fd004172-5eb0-4c25-8e5b-1e0b0b4c9b5e
SDNHostwEgressIP
['"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func SDNHostwEgressIP(oc *exutil.CLI, node []string, egressip string) string { var ip []string var foundHost string for i := 0; i < len(node); i++ { iplist, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("hostsubnet", node[i], "-o=jsonpath={.egressIPs}").Output() e2e.Logf("iplist for node %v: %v", node, iplist) if iplist != "" && iplist != "[]" { ip = strings.Split(iplist[2:len(iplist)-2], "\",\"") } if iplist == "" || iplist == "[]" || err != nil { err = wait.Poll(30*time.Second, 3*time.Minute, func() (bool, error) { iplist, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("hostsubnet", node[i], "-o=jsonpath={.egressIPs}").Output() if iplist != "" && iplist != "[]" { e2e.Logf("Found egressIP list for node %v is: %v", node, iplist) ip = strings.Split(iplist[2:len(iplist)-2], "\",\"") return true, nil } if err != nil { e2e.Logf("only got %d egressIP, or have err:%v, and try next round", len(ip), err) return false, nil } return false, nil }) } if isValueInList(egressip, ip) { foundHost = node[i] break } } return foundHost }
networking
function
openshift/openshift-tests-private
23e99e58-ed02-44a4-b102-17b14567922d
isValueInList
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func isValueInList(value string, list []string) bool { for _, v := range list { if v == value { return true } } return false }
networking
function
openshift/openshift-tests-private
b5cd68db-a152-4a3f-a337-1d228cc4e971
getPodMultiNetwork
['"strings"', '"time"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getPodMultiNetwork(oc *exutil.CLI, namespace string, podName string) (string, string) { cmd1 := "ip -o -4 addr show dev net1 | awk '$3 == \"inet\" {print $4}' | cut -d'/' -f1" cmd2 := "ip -o -6 addr show dev net1 | awk '$3 == \"inet6\" {print $4}' | head -1 | cut -d'/' -f1" podIPv4, err := e2eoutput.RunHostCmdWithRetries(namespace, podName, cmd1, 2*time.Second, 10*time.Second) o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("pod net1 ipv4 is: %s", podIPv4) o.Expect(podIPv4).NotTo(o.BeNil()) podipv4 := strings.TrimSpace(podIPv4) podIPv6, err1 := e2eoutput.RunHostCmdWithRetries(namespace, podName, cmd2, 2*time.Second, 10*time.Second) o.Expect(err1).NotTo(o.HaveOccurred()) e2e.Logf("pod net1 ipv6 is: %s", podIPv6) o.Expect(podIPv6).NotTo(o.BeNil()) podipv6 := strings.TrimSpace(podIPv6) e2e.Logf("The v4 address of %s is: %v", podName, podipv4) e2e.Logf("The v4 address of %s is: %v", podName, podipv6) return podipv4, podipv6 }
networking
function
openshift/openshift-tests-private
23d170f4-d603-417f-ab87-ff3db211815d
curlPod2PodMultiNetworkPass
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func curlPod2PodMultiNetworkPass(oc *exutil.CLI, namespaceSrc string, podNameSrc string, podIPv4 string, podIPv6 string) { // Poll to check IPv4 connectivity err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl "+podIPv4+":8080 --connect-timeout 5") if !strings.Contains(msg, "Hello OpenShift!") { e2e.Logf("The curl should pass but fail, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Test fail with err:%s", err)) // Poll to check IPv6 connectivity err1 := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg1, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl -g -6 ["+podIPv6+"]:8080 --connect-timeout 5") if !strings.Contains(msg1, "Hello OpenShift!") { e2e.Logf("The curl should pass but fail, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err1, fmt.Sprintf("Test fail with err:%s", err1)) }
networking
function
openshift/openshift-tests-private
875b6021-cb45-4c21-926c-ba2f1012c02b
curlPod2PodMultiNetworkFail
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func curlPod2PodMultiNetworkFail(oc *exutil.CLI, namespaceSrc string, podNameSrc string, podIPv4 string, podIPv6 string) { // Poll to check IPv4 connectivity err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl "+podIPv4+":8080 --connect-timeout 5") if strings.Contains(msg, "Hello OpenShift!") { e2e.Logf("The curl should fail but pass, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Test fail with err:%s", err)) // Poll to check IPv6 connectivity err1 := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg1, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl -g -6 ["+podIPv6+"]:8080 --connect-timeout 5") if strings.Contains(msg1, "Hello OpenShift!") { e2e.Logf("The curl should fail but pass, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err1, fmt.Sprintf("Test fail with err:%s", err1)) }
networking
function
openshift/openshift-tests-private
0063c068-46a8-49da-b3d1-430f50ed41a5
curlPod2PodMultiNetworkIPBlockPass
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func curlPod2PodMultiNetworkIPBlockPass(oc *exutil.CLI, namespaceSrc string, podNameSrc string, podIPv4 string, podIPv6 string) { err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl "+podIPv4+":8080 --connect-timeout 5") if !strings.Contains(msg, "Hello OpenShift!") { e2e.Logf("The curl should pass but fail, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Test fail with err:%s", err)) }
networking
function
openshift/openshift-tests-private
59598a95-83e6-4475-b64c-728541037c17
curlPod2PodMultiNetworkIPBlockFail
['"context"', '"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func curlPod2PodMultiNetworkIPBlockFail(oc *exutil.CLI, namespaceSrc string, podNameSrc string, podIPv4 string, podIPv6 string) { err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { msg, _ := e2eoutput.RunHostCmd(namespaceSrc, podNameSrc, "curl "+podIPv4+":8080 --connect-timeout 5") if strings.Contains(msg, "Hello OpenShift!") { e2e.Logf("The curl should fail but pass, and try next round") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("Test fail with err:%s", err)) }
networking
function
openshift/openshift-tests-private
2f2987cc-f8b7-4111-a7b4-438d72aff27a
prepareMultinetworkTest
['"io"', '"net"', '"path/filepath"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"', 'netutils "k8s.io/utils/net"']
['testPodMultinetwork']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func prepareMultinetworkTest(oc *exutil.CLI, ns1 string, ns2 string, patchInfo string) { buildPruningBaseDir := exutil.FixturePath("testdata", "networking/multinetworkpolicy") netAttachDefFile1 := filepath.Join(buildPruningBaseDir, "MultiNetworkPolicy-NAD1.yaml") netAttachDefFile2 := filepath.Join(buildPruningBaseDir, "MultiNetworkPolicy-NAD2.yaml") pingPodTemplate := filepath.Join(buildPruningBaseDir, "MultiNetworkPolicy-pod-template.yaml") patchSResource := "networks.operator.openshift.io/cluster" exutil.By("Enable MacvlanNetworkpolicy in the cluster") patchResourceAsAdmin(oc, patchSResource, patchInfo) waitForNetworkOperatorState(oc, 20, 10, "True.*True.*False") waitForNetworkOperatorState(oc, 20, 20, "True.*False.*False") exutil.By("Create MultiNetworkPolicy-NAD1 in ns1") err1 := oc.AsAdmin().Run("create").Args("-f", netAttachDefFile1, "-n", ns1).Execute() o.Expect(err1).NotTo(o.HaveOccurred()) output, err2 := oc.AsAdmin().Run("get").Args("net-attach-def", "-n", ns1).Output() o.Expect(err2).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("macvlan-nad1")) exutil.By("Create 1st pod in ns1") pod1ns1 := testPodMultinetwork{ name: "blue-pod-1", namespace: ns1, nodename: "worker-0", nadname: "macvlan-nad1", labelname: "blue-openshift", template: pingPodTemplate, } pod1ns1.createTestPodMultinetwork(oc) waitPodReady(oc, pod1ns1.namespace, pod1ns1.name) exutil.By("Create second pod in ns1") pod2ns1 := testPodMultinetwork{ name: "blue-pod-2", namespace: ns1, nodename: "worker-1", nadname: "macvlan-nad1", labelname: "blue-openshift", template: pingPodTemplate, } pod2ns1.createTestPodMultinetwork(oc) waitPodReady(oc, pod2ns1.namespace, pod2ns1.name) exutil.By("Create third pod in ns1") pod3ns1 := testPodMultinetwork{ name: "red-pod-1", namespace: ns1, nodename: "worker-0", nadname: "macvlan-nad1", labelname: "red-openshift", template: pingPodTemplate, } pod3ns1.createTestPodMultinetwork(oc) waitPodReady(oc, pod3ns1.namespace, pod3ns1.name) exutil.By("Create MultiNetworkPolicy-NAD2 in ns2") err4 := oc.AsAdmin().WithoutNamespace().Run("create").Args("-f", netAttachDefFile2, "-n", ns2).Execute() o.Expect(err4).NotTo(o.HaveOccurred()) output, err5 := oc.AsAdmin().Run("get").Args("net-attach-def", "-n", ns2).Output() o.Expect(err5).NotTo(o.HaveOccurred()) o.Expect(output).To(o.ContainSubstring("macvlan-nad2")) exutil.By("Create 1st pod in ns2") pod1ns2 := testPodMultinetwork{ name: "blue-pod-3", namespace: ns2, nodename: "worker-0", nadname: "macvlan-nad2", labelname: "blue-openshift", template: pingPodTemplate, } pod1ns2.createTestPodMultinetwork(oc) waitPodReady(oc, pod1ns2.namespace, pod1ns2.name) exutil.By("Create second pod in ns2") pod2ns2 := testPodMultinetwork{ name: "red-pod-2", namespace: ns2, nodename: "worker-0", nadname: "macvlan-nad2", labelname: "red-openshift", template: pingPodTemplate, } pod2ns2.createTestPodMultinetwork(oc) waitPodReady(oc, pod2ns2.namespace, pod2ns2.name) }
networking
function
openshift/openshift-tests-private
75e15058-639e-495d-ac96-3ccdf143f8d9
checkPrimaryNIC
['"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkPrimaryNIC(oc *exutil.CLI, nodeName string, ip string, flag bool) { checkErr := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { output, err := exutil.DebugNodeWithChroot(oc, nodeName, "bash", "-c", "/usr/sbin/ip -4 -brief address show") if err != nil { e2e.Logf("Cannot get primary NIC interface, errors: %v, try again", err) return false, nil } if flag && !strings.Contains(output, ip) { e2e.Logf("egressIP has not been added to node's NIC correctly, try again") return false, nil } if !flag && strings.Contains(output, ip) { e2e.Logf("egressIP has not been removed from node's NIC correctly, try again") return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(checkErr, fmt.Sprintf("Failed to get NIC on the host:%s", checkErr)) }
networking
function
openshift/openshift-tests-private
38fbfa0d-22c7-42f8-a694-138475649844
checkEgressIPonSDNHost
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkEgressIPonSDNHost(oc *exutil.CLI, node string, expectedEgressIP []string) { checkErr := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { ip, err := getEgressIPByKind(oc, "hostsubnet", node, len(expectedEgressIP)) if err != nil { e2e.Logf("\n got the error: %v\n, try again", err) return false, nil } if !unorderedEqual(ip, expectedEgressIP) { e2e.Logf("\n got egressIP as %v while expected egressIP is %v, try again", ip, expectedEgressIP) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(checkErr, fmt.Sprintf("Failed to get egressIP on the host:%s", checkErr)) }
networking
function
openshift/openshift-tests-private
b4882d5e-3cce-43ce-8f5c-a6058d562d99
unorderedEqual
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func unorderedEqual(first, second []string) bool { if len(first) != len(second) { return false } for _, value := range first { if !contains(second, value) { return false } } return true }
networking
function
openshift/openshift-tests-private
8b1ac38e-1612-4e59-a47b-6c09a1b6106c
checkovnkubeMasterNetworkProgrammingetrics
['"fmt"', '"os/exec"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkovnkubeMasterNetworkProgrammingetrics(oc *exutil.CLI, url string, metrics string) { var metricsOutput []byte olmToken, err := exutil.GetSAToken(oc) o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(olmToken).NotTo(o.BeEmpty()) metricsErr := wait.Poll(5*time.Second, 10*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("exec").Args("-n", "openshift-monitoring", "-c", "prometheus", "prometheus-k8s-0", "--", "curl", "-k", "-H", fmt.Sprintf("Authorization: Bearer %v", olmToken), fmt.Sprintf("%s", url)).OutputToFile("metrics.txt") if err != nil { e2e.Logf("Can't get metrics and try again, the error is:%s", err) return false, nil } metricsOutput, _ = exec.Command("bash", "-c", "cat "+output+" | grep "+metrics+" | awk 'NR==2{print $2}'").Output() metricsValue := strings.TrimSpace(string(metricsOutput)) if metricsValue != "" { e2e.Logf("The output of the metrics for %s is : %v", metrics, metricsValue) } else { e2e.Logf("Can't get metrics for %s:", metrics) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(metricsErr, fmt.Sprintf("Fail to get metric and the error is:%s", metricsErr)) }
networking
function
openshift/openshift-tests-private
b5b7110a-a2e5-46db-900f-fac36a304397
getControllerManagerLeaderIP
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getControllerManagerLeaderIP(oc *exutil.CLI) string { leaderPodName, leaderErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("lease", "openshift-master-controllers", "-n", "openshift-controller-manager", "-o=jsonpath={.spec.holderIdentity}").Output() o.Expect(leaderErr).NotTo(o.HaveOccurred()) o.Expect(leaderPodName).ShouldNot(o.BeEmpty(), "leader pod name is empty") e2e.Logf("The leader pod name is %s", leaderPodName) leaderPodIP := getPodIPv4(oc, "openshift-controller-manager", leaderPodName) return leaderPodIP }
networking
function
openshift/openshift-tests-private
2af17fcc-ceb8-4155-8f92-685bcbab689d
describeCheckEgressIPByKind
['"regexp"', '"strings"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func describeCheckEgressIPByKind(oc *exutil.CLI, kind string, kindName string) string { output, err := oc.AsAdmin().WithoutNamespace().Run("describe").Args(kind, kindName).Output() o.Expect(err).NotTo(o.HaveOccurred()) egressIPReg, _ := regexp.Compile(".*Egress IPs.*") egressIPStr := egressIPReg.FindString(output) egressIPArr := strings.Split(egressIPStr, ":") //remove whitespace in front of the ip address ip := strings.TrimSpace(egressIPArr[1]) e2e.Logf("get egressIP from oc describe %v %v: --->%s<---", kind, kindName, ip) return ip }
networking
function
openshift/openshift-tests-private
47ffa2e4-7e8b-44a3-bc8b-9593fa1891ae
findUnUsedIPsOnNodeOrFail
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func findUnUsedIPsOnNodeOrFail(oc *exutil.CLI, nodeName, cidr string, expectedNum int) []string { freeIPs := findUnUsedIPsOnNode(oc, nodeName, cidr, expectedNum) if len(freeIPs) != expectedNum { g.Skip("Did not get enough free IPs for the test, skip the test.") } return freeIPs }
networking
function
openshift/openshift-tests-private
10a19536-2e61-4056-a774-01b3da965f62
createExternalIPPod
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
['externalIPPod']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (pod *externalIPPod) createExternalIPPod(oc *exutil.CLI) { err := wait.Poll(5*time.Second, 20*time.Second, func() (bool, error) { err1 := applyResourceFromTemplate(oc, "--ignore-unknown-parameters=true", "-f", pod.template, "-p", "NAME="+pod.name, "NAMESPACE="+pod.namespace) if err1 != nil { e2e.Logf("the err:%v, and try next round", err1) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("fail to create the externalIP pod %v", pod.name)) }
networking
function
openshift/openshift-tests-private
8d2c85d4-eaa3-4dd1-8d8e-f67a17f8f75b
checkParameter
['e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkParameter(oc *exutil.CLI, namespace string, kind string, kindName string, parameter string) string { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("-n", namespace, kind, kindName, parameter).Output() o.Expect(err).NotTo(o.HaveOccurred()) return output }
networking
function
openshift/openshift-tests-private
0baf02c4-66bc-4ff4-900c-80aae7bf7e32
patchReplaceResourceAsAdmin
['"encoding/json"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func patchReplaceResourceAsAdmin(oc *exutil.CLI, resource, patch string, nameSpace ...string) { var cargs []string if len(nameSpace) > 0 { cargs = []string{resource, "-p", patch, "-n", nameSpace[0], "--type=json"} } else { cargs = []string{resource, "-p", patch, "--type=json"} } err := oc.AsAdmin().WithoutNamespace().Run("patch").Args(cargs...).Execute() o.Expect(err).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
4b867e4c-ba52-4c69-a3cf-b679d75271ee
getNodeSubnet
['"encoding/json"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getNodeSubnet(oc *exutil.CLI, nodeName string, network string) string { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", nodeName, "-o=jsonpath={.metadata.annotations.k8s\\.ovn\\.org/node-subnets}").Output() o.Expect(err).NotTo(o.HaveOccurred()) var data map[string]interface{} json.Unmarshal([]byte(output), &data) hostSubnets := data[network].([]interface{}) hostSubnet := hostSubnets[0].(string) return hostSubnet }
networking
function
openshift/openshift-tests-private
471d9080-7f7c-436b-9b74-42d58c407897
getNodeSubnetDualStack
['"encoding/json"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getNodeSubnetDualStack(oc *exutil.CLI, nodeName string, network string) (string, string) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", nodeName, "-o=jsonpath={.metadata.annotations.k8s\\.ovn\\.org/node-subnets}").Output() o.Expect(err).NotTo(o.HaveOccurred()) var data map[string]interface{} json.Unmarshal([]byte(output), &data) hostSubnets := data[network].([]interface{}) hostSubnetIPv4 := hostSubnets[0].(string) hostSubnetIPv6 := hostSubnets[1].(string) e2e.Logf("Host subnet is %v and %v", hostSubnetIPv4, hostSubnetIPv6) return hostSubnetIPv4, hostSubnetIPv6 }
networking
function
openshift/openshift-tests-private
7cefda1c-fa53-4cb5-827c-265622b25c36
getIPv4Capacity
['"io"', '"strings"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getIPv4Capacity(oc *exutil.CLI, nodeName string) string { ipv4Capacity := "" egressIPConfig, err := oc.WithoutNamespace().AsAdmin().Run("get").Args("node", nodeName, "-o=jsonpath={.metadata.annotations.cloud\\.network\\.openshift\\.io/egress-ipconfig}").Output() o.Expect(err).NotTo(o.HaveOccurred()) e2e.Logf("The egressipconfig is %v \n", egressIPConfig) switch exutil.CheckPlatform(oc) { case "aws": ipv4Capacity = strings.Split(strings.Split(egressIPConfig, ":")[5], ",")[0] case "gcp": ipv4Capacity = strings.Split(egressIPConfig, ":")[5] ipv4Capacity = ipv4Capacity[:len(ipv4Capacity)-3] default: e2e.Logf("Not support cloud provider for auto egressip cases for now.") g.Skip("Not support cloud provider for auto egressip cases for now.") } return ipv4Capacity }
networking
function
openshift/openshift-tests-private
c6a07c0a-27b1-4b91-aaa9-af046ce32a4b
getJSONString
['"encoding/json"']
['aclSettings']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func (aclSettings *aclSettings) getJSONString() string { jsonACLSetting, _ := json.Marshal(aclSettings) annotationString := "k8s.ovn.org/acl-logging=" + string(jsonACLSetting) return annotationString }
networking
function
openshift/openshift-tests-private
e311db1c-bed9-4e60-9e8f-9649eedbb25d
enableACLOnNamespace
['aclSettings']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func enableACLOnNamespace(oc *exutil.CLI, namespace, denyLevel, allowLevel string) { e2e.Logf("Enable ACL looging on the namespace %s", namespace) aclSettings := aclSettings{DenySetting: denyLevel, AllowSetting: allowLevel} err1 := oc.AsAdmin().WithoutNamespace().Run("annotate").Args("--overwrite", "ns", namespace, aclSettings.getJSONString()).Execute() o.Expect(err1).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
4d5704c8-f7ed-4973-84df-33eb7ca141b2
disableACLOnNamespace
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func disableACLOnNamespace(oc *exutil.CLI, namespace string) { e2e.Logf("Disable ACL looging on the namespace %s", namespace) err1 := oc.AsAdmin().WithoutNamespace().Run("annotate").Args("ns", namespace, "k8s.ovn.org/acl-logging-").Execute() o.Expect(err1).NotTo(o.HaveOccurred()) }
networking
function
openshift/openshift-tests-private
94741417-3355-48bd-bec4-afbaf11b1d7d
getNodeMacAddress
['"encoding/json"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getNodeMacAddress(oc *exutil.CLI, nodeName string) string { var macAddress string output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("node", nodeName, "-o=jsonpath={.metadata.annotations.k8s\\.ovn\\.org/l3-gateway-config}").Output() o.Expect(err).NotTo(o.HaveOccurred()) var data map[string]interface{} json.Unmarshal([]byte(output), &data) l3GatewayConfigAnnotations := data["default"].(interface{}) l3GatewayConfigAnnotationsJSON := l3GatewayConfigAnnotations.(map[string]interface{}) macAddress = l3GatewayConfigAnnotationsJSON["mac-address"].(string) return macAddress }
networking
function
openshift/openshift-tests-private
efaafbb5-c681-4cb8-a9ea-6deaae16b915
checkEnvInConfigMap
['"fmt"', '"strings"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkEnvInConfigMap(oc *exutil.CLI, ns, configmapName string, envString string) error { err := checkConfigMap(oc, ns, configmapName) exutil.AssertWaitPollNoErr(err, fmt.Sprintf("cm %v is not found in namespace %v", configmapName, ns)) checkErr := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("configmap", "-n", ns, configmapName, "-oyaml").Output() if err != nil { e2e.Logf("Failed to get configmap %v, error: %s. Trying again", configmapName, err) return false, nil } if !strings.Contains(output, envString) { e2e.Logf("Did not find %v in ovnkube-config configmap,try next round.", envString) return false, nil } return true, nil }) return checkErr }
networking
function
openshift/openshift-tests-private
b89fe254-b65e-4c3b-9624-7a60ceeb1a15
checkLogMessageInPod
['"fmt"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func checkLogMessageInPod(oc *exutil.CLI, namespace string, containerName string, podName string, filter string) (string, error) { var podLogs string var err, checkErr error checkErr = wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { podLogs, err = exutil.GetSpecificPodLogsCombinedOrNot(oc, namespace, containerName, podName, filter, true) if len(podLogs) == 0 || err != nil { e2e.Logf("did not get expected podLogs: %v, or have err:%v, try again", podLogs, err) return false, nil } return true, nil }) if checkErr != nil { return podLogs, fmt.Errorf(fmt.Sprintf("fail to get expected log in pod %v, err: %v", podName, err)) } return podLogs, nil }
networking
function
openshift/openshift-tests-private
ba0cb638-da6e-43c4-9cb5-a7a318531bdf
getOVNK8sNodeMgmtIPv4
['"fmt"', '"regexp"', '"time"', '"k8s.io/apimachinery/pkg/util/wait"', 'e2enode "k8s.io/kubernetes/test/e2e/framework/node"', 'e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"']
github.com/openshift/openshift-tests-private/test/extended/networking/utils.go
func getOVNK8sNodeMgmtIPv4(oc *exutil.CLI, nodeName string) string { var output string var err error checkErr := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) { output, err = exutil.DebugNodeWithChroot(oc, nodeName, "bash", "-c", "/usr/sbin/ip -4 -brief address show | grep ovn-k8s-mp0") if output == "" || err != nil { e2e.Logf("Did not get node's management interface, errors: %v, try again", err) return false, nil } return true, nil }) exutil.AssertWaitPollNoErr(checkErr, fmt.Sprintf("fail to get management interface for node %v, err: %v", nodeName, checkErr)) e2e.Logf("Match out the OVN-Kubernetes management IP address for the node") re := regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`) nodeOVNK8sMgmtIP := re.FindAllString(output, -1)[0] e2e.Logf("Got ovn-k8s management interface IP for node %v as: %v", nodeName, nodeOVNK8sMgmtIP) return nodeOVNK8sMgmtIP }
networking