Merge pull request #83817 from oomichi/rename-framework-funcs

Rename e2e framework functions used locally
This commit is contained in:
Kubernetes Prow Robot 2019-10-12 17:34:37 -07:00 committed by GitHub
commit 743031d793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 17 deletions

View File

@ -104,7 +104,7 @@ func CreatePod(client clientset.Interface, namespace string, nodeSelector map[st
// CreateNginxPod creates an enginx pod. // CreateNginxPod creates an enginx pod.
func CreateNginxPod(client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim) (*v1.Pod, error) { func CreateNginxPod(client clientset.Interface, namespace string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim) (*v1.Pod, error) {
pod := MakeNginxPod(namespace, nodeSelector, pvclaims) pod := makeNginxPod(namespace, nodeSelector, pvclaims)
pod, err := client.CoreV1().Pods(namespace).Create(pod) pod, err := client.CoreV1().Pods(namespace).Create(pod)
if err != nil { if err != nil {
return nil, fmt.Errorf("pod Create API error: %v", err) return nil, fmt.Errorf("pod Create API error: %v", err)
@ -198,8 +198,8 @@ func MakePod(ns string, nodeSelector map[string]string, pvclaims []*v1.Persisten
return podSpec return podSpec
} }
// MakeNginxPod returns a pod definition based on the namespace using nginx image // makeNginxPod returns a pod definition based on the namespace using nginx image
func MakeNginxPod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim) *v1.Pod { func makeNginxPod(ns string, nodeSelector map[string]string, pvclaims []*v1.PersistentVolumeClaim) *v1.Pod {
podSpec := &v1.Pod{ podSpec := &v1.Pod{
TypeMeta: metav1.TypeMeta{ TypeMeta: metav1.TypeMeta{
Kind: "Pod", Kind: "Pod",

View File

@ -28,8 +28,8 @@ type NodeSelection struct {
Affinity *v1.Affinity Affinity *v1.Affinity
} }
// SetNodeAffinityRequirement sets affinity with specified operator to nodeName to nodeSelection // setNodeAffinityRequirement sets affinity with specified operator to nodeName to nodeSelection
func SetNodeAffinityRequirement(nodeSelection *NodeSelection, operator v1.NodeSelectorOperator, nodeName string) { func setNodeAffinityRequirement(nodeSelection *NodeSelection, operator v1.NodeSelectorOperator, nodeName string) {
// Add node-anti-affinity. // Add node-anti-affinity.
if nodeSelection.Affinity == nil { if nodeSelection.Affinity == nil {
nodeSelection.Affinity = &v1.Affinity{} nodeSelection.Affinity = &v1.Affinity{}
@ -50,10 +50,10 @@ func SetNodeAffinityRequirement(nodeSelection *NodeSelection, operator v1.NodeSe
// SetAffinity sets affinity to nodeName to nodeSelection // SetAffinity sets affinity to nodeName to nodeSelection
func SetAffinity(nodeSelection *NodeSelection, nodeName string) { func SetAffinity(nodeSelection *NodeSelection, nodeName string) {
SetNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpIn, nodeName) setNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpIn, nodeName)
} }
// SetAntiAffinity sets anti-affinity to nodeName to nodeSelection // SetAntiAffinity sets anti-affinity to nodeName to nodeSelection
func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string) { func SetAntiAffinity(nodeSelection *NodeSelection, nodeName string) {
SetNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpNotIn, nodeName) setNodeAffinityRequirement(nodeSelection, v1.NodeSelectorOpNotIn, nodeName)
} }

View File

@ -389,9 +389,9 @@ func LogPodStates(pods []v1.Pod) {
e2elog.Logf("") // Final empty line helps for readability. e2elog.Logf("") // Final empty line helps for readability.
} }
// LogPodTerminationMessages logs termination messages for failing pods. It's a short snippet (much smaller than full logs), but it often shows // logPodTerminationMessages logs termination messages for failing pods. It's a short snippet (much smaller than full logs), but it often shows
// why pods crashed and since it is in the API, it's fast to retrieve. // why pods crashed and since it is in the API, it's fast to retrieve.
func LogPodTerminationMessages(pods []v1.Pod) { func logPodTerminationMessages(pods []v1.Pod) {
for _, pod := range pods { for _, pod := range pods {
for _, status := range pod.Status.InitContainerStatuses { for _, status := range pod.Status.InitContainerStatuses {
if status.LastTerminationState.Terminated != nil && len(status.LastTerminationState.Terminated.Message) > 0 { if status.LastTerminationState.Terminated != nil && len(status.LastTerminationState.Terminated.Message) > 0 {
@ -413,7 +413,7 @@ func DumpAllPodInfoForNamespace(c clientset.Interface, namespace string) {
e2elog.Logf("unable to fetch pod debug info: %v", err) e2elog.Logf("unable to fetch pod debug info: %v", err)
} }
LogPodStates(pods.Items) LogPodStates(pods.Items)
LogPodTerminationMessages(pods.Items) logPodTerminationMessages(pods.Items)
} }
// FilterNonRestartablePods filters out pods that will never get recreated if // FilterNonRestartablePods filters out pods that will never get recreated if
@ -551,19 +551,19 @@ func CreatePodOrFail(c clientset.Interface, ns, name string, labels map[string]s
// podNames in namespace ns are running and ready, using c and waiting at most // podNames in namespace ns are running and ready, using c and waiting at most
// timeout. // timeout.
func CheckPodsRunningReady(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool { func CheckPodsRunningReady(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool {
return CheckPodsCondition(c, ns, podNames, timeout, testutils.PodRunningReady, "running and ready") return checkPodsCondition(c, ns, podNames, timeout, testutils.PodRunningReady, "running and ready")
} }
// CheckPodsRunningReadyOrSucceeded returns whether all pods whose names are // CheckPodsRunningReadyOrSucceeded returns whether all pods whose names are
// listed in podNames in namespace ns are running and ready, or succeeded; use // listed in podNames in namespace ns are running and ready, or succeeded; use
// c and waiting at most timeout. // c and waiting at most timeout.
func CheckPodsRunningReadyOrSucceeded(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool { func CheckPodsRunningReadyOrSucceeded(c clientset.Interface, ns string, podNames []string, timeout time.Duration) bool {
return CheckPodsCondition(c, ns, podNames, timeout, testutils.PodRunningReadyOrSucceeded, "running and ready, or succeeded") return checkPodsCondition(c, ns, podNames, timeout, testutils.PodRunningReadyOrSucceeded, "running and ready, or succeeded")
} }
// CheckPodsCondition returns whether all pods whose names are listed in podNames // checkPodsCondition returns whether all pods whose names are listed in podNames
// in namespace ns are in the condition, using c and waiting at most timeout. // in namespace ns are in the condition, using c and waiting at most timeout.
func CheckPodsCondition(c clientset.Interface, ns string, podNames []string, timeout time.Duration, condition podCondition, desc string) bool { func checkPodsCondition(c clientset.Interface, ns string, podNames []string, timeout time.Duration, condition podCondition, desc string) bool {
np := len(podNames) np := len(podNames)
e2elog.Logf("Waiting up to %v for %d pods to be %s: %s", timeout, np, desc, podNames) e2elog.Logf("Waiting up to %v for %d pods to be %s: %s", timeout, np, desc, podNames)
type waitPodResult struct { type waitPodResult struct {

View File

@ -162,7 +162,7 @@ func SSH(cmd, host, provider string) (Result, error) {
} }
if bastion := os.Getenv("KUBE_SSH_BASTION"); len(bastion) > 0 { if bastion := os.Getenv("KUBE_SSH_BASTION"); len(bastion) > 0 {
stdout, stderr, code, err := RunSSHCommandViaBastion(cmd, result.User, bastion, host, signer) stdout, stderr, code, err := runSSHCommandViaBastion(cmd, result.User, bastion, host, signer)
result.Stdout = stdout result.Stdout = stdout
result.Stderr = stderr result.Stderr = stderr
result.Code = code result.Code = code
@ -177,11 +177,11 @@ func SSH(cmd, host, provider string) (Result, error) {
return result, err return result, err
} }
// RunSSHCommandViaBastion returns the stdout, stderr, and exit code from running cmd on // runSSHCommandViaBastion returns the stdout, stderr, and exit code from running cmd on
// host as specific user, along with any SSH-level error. It uses an SSH proxy to connect // host as specific user, along with any SSH-level error. It uses an SSH proxy to connect
// to bastion, then via that tunnel connects to the remote host. Similar to // to bastion, then via that tunnel connects to the remote host. Similar to
// sshutil.RunSSHCommand but scoped to the needs of the test infrastructure. // sshutil.RunSSHCommand but scoped to the needs of the test infrastructure.
func RunSSHCommandViaBastion(cmd, user, bastion, host string, signer ssh.Signer) (string, string, int, error) { func runSSHCommandViaBastion(cmd, user, bastion, host string, signer ssh.Signer) (string, string, int, error) {
// Setup the config, dial the server, and open a session. // Setup the config, dial the server, and open a session.
config := &ssh.ClientConfig{ config := &ssh.ClientConfig{
User: user, User: user,