e2e: adapt to moved code

This is the result of automatically editing source files like this:

    go install golang.org/x/tools/cmd/goimports@latest
    find ./test/e2e* -name "*.go" | xargs env PATH=$GOPATH/bin:$PATH ./e2e-framework-sed.sh

with e2e-framework-sed.sh containing this:

sed -i \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecCommandInContainer(/e2epod.ExecCommandInContainer(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecCommandInContainerWithFullOutput(/e2epod.ExecCommandInContainerWithFullOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInContainer(/e2epod.ExecShellInContainer(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInPod(/e2epod.ExecShellInPod(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecShellInPodWithFullOutput(/e2epod.ExecShellInPodWithFullOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.ExecWithOptions(/e2epod.ExecWithOptions(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.MatchContainerOutput(/e2eoutput.MatchContainerOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.PodClient(/e2epod.NewPodClient(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.PodClientNS(/e2epod.PodClientNS(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.TestContainerOutput(/e2eoutput.TestContainerOutput(\1, /" \
    -e "s/\(f\|fr\|\w\w*\.[fF]\w*\)\.TestContainerOutputRegexp(/e2eoutput.TestContainerOutputRegexp(\1, /" \
    -e "s/framework.AddOrUpdateLabelOnNode\b/e2enode.AddOrUpdateLabelOnNode/" \
    -e "s/framework.AllNodes\b/e2edebug.AllNodes/" \
    -e "s/framework.AllNodesReady\b/e2enode.AllNodesReady/" \
    -e "s/framework.ContainerResourceGatherer\b/e2edebug.ContainerResourceGatherer/" \
    -e "s/framework.ContainerResourceUsage\b/e2edebug.ContainerResourceUsage/" \
    -e "s/framework.CreateEmptyFileOnPod\b/e2eoutput.CreateEmptyFileOnPod/" \
    -e "s/framework.DefaultPodDeletionTimeout\b/e2epod.DefaultPodDeletionTimeout/" \
    -e "s/framework.DumpAllNamespaceInfo\b/e2edebug.DumpAllNamespaceInfo/" \
    -e "s/framework.DumpDebugInfo\b/e2eoutput.DumpDebugInfo/" \
    -e "s/framework.DumpNodeDebugInfo\b/e2edebug.DumpNodeDebugInfo/" \
    -e "s/framework.EtcdUpgrade\b/e2eproviders.EtcdUpgrade/" \
    -e "s/framework.EventsLister\b/e2edebug.EventsLister/" \
    -e "s/framework.ExecOptions\b/e2epod.ExecOptions/" \
    -e "s/framework.ExpectNodeHasLabel\b/e2enode.ExpectNodeHasLabel/" \
    -e "s/framework.ExpectNodeHasTaint\b/e2enode.ExpectNodeHasTaint/" \
    -e "s/framework.GCEUpgradeScript\b/e2eproviders.GCEUpgradeScript/" \
    -e "s/framework.ImagePrePullList\b/e2epod.ImagePrePullList/" \
    -e "s/framework.KubectlBuilder\b/e2ekubectl.KubectlBuilder/" \
    -e "s/framework.LocationParamGKE\b/e2eproviders.LocationParamGKE/" \
    -e "s/framework.LogSizeDataTimeseries\b/e2edebug.LogSizeDataTimeseries/" \
    -e "s/framework.LogSizeGatherer\b/e2edebug.LogSizeGatherer/" \
    -e "s/framework.LogsSizeData\b/e2edebug.LogsSizeData/" \
    -e "s/framework.LogsSizeDataSummary\b/e2edebug.LogsSizeDataSummary/" \
    -e "s/framework.LogsSizeVerifier\b/e2edebug.LogsSizeVerifier/" \
    -e "s/framework.LookForStringInLog\b/e2eoutput.LookForStringInLog/" \
    -e "s/framework.LookForStringInPodExec\b/e2eoutput.LookForStringInPodExec/" \
    -e "s/framework.LookForStringInPodExecToContainer\b/e2eoutput.LookForStringInPodExecToContainer/" \
    -e "s/framework.MasterAndDNSNodes\b/e2edebug.MasterAndDNSNodes/" \
    -e "s/framework.MasterNodes\b/e2edebug.MasterNodes/" \
    -e "s/framework.MasterUpgradeGKE\b/e2eproviders.MasterUpgradeGKE/" \
    -e "s/framework.NewKubectlCommand\b/e2ekubectl.NewKubectlCommand/" \
    -e "s/framework.NewLogsVerifier\b/e2edebug.NewLogsVerifier/" \
    -e "s/framework.NewNodeKiller\b/e2enode.NewNodeKiller/" \
    -e "s/framework.NewResourceUsageGatherer\b/e2edebug.NewResourceUsageGatherer/" \
    -e "s/framework.NodeHasTaint\b/e2enode.NodeHasTaint/" \
    -e "s/framework.NodeKiller\b/e2enode.NodeKiller/" \
    -e "s/framework.NodesSet\b/e2edebug.NodesSet/" \
    -e "s/framework.PodClient\b/e2epod.PodClient/" \
    -e "s/framework.RemoveLabelOffNode\b/e2enode.RemoveLabelOffNode/" \
    -e "s/framework.ResourceConstraint\b/e2edebug.ResourceConstraint/" \
    -e "s/framework.ResourceGathererOptions\b/e2edebug.ResourceGathererOptions/" \
    -e "s/framework.ResourceUsagePerContainer\b/e2edebug.ResourceUsagePerContainer/" \
    -e "s/framework.ResourceUsageSummary\b/e2edebug.ResourceUsageSummary/" \
    -e "s/framework.RunHostCmd\b/e2eoutput.RunHostCmd/" \
    -e "s/framework.RunHostCmdOrDie\b/e2eoutput.RunHostCmdOrDie/" \
    -e "s/framework.RunHostCmdWithFullOutput\b/e2eoutput.RunHostCmdWithFullOutput/" \
    -e "s/framework.RunHostCmdWithRetries\b/e2eoutput.RunHostCmdWithRetries/" \
    -e "s/framework.RunKubectl\b/e2ekubectl.RunKubectl/" \
    -e "s/framework.RunKubectlInput\b/e2ekubectl.RunKubectlInput/" \
    -e "s/framework.RunKubectlOrDie\b/e2ekubectl.RunKubectlOrDie/" \
    -e "s/framework.RunKubectlOrDieInput\b/e2ekubectl.RunKubectlOrDieInput/" \
    -e "s/framework.RunKubectlWithFullOutput\b/e2ekubectl.RunKubectlWithFullOutput/" \
    -e "s/framework.RunKubemciCmd\b/e2ekubectl.RunKubemciCmd/" \
    -e "s/framework.RunKubemciWithKubeconfig\b/e2ekubectl.RunKubemciWithKubeconfig/" \
    -e "s/framework.SingleContainerSummary\b/e2edebug.SingleContainerSummary/" \
    -e "s/framework.SingleLogSummary\b/e2edebug.SingleLogSummary/" \
    -e "s/framework.TimestampedSize\b/e2edebug.TimestampedSize/" \
    -e "s/framework.WaitForAllNodesSchedulable\b/e2enode.WaitForAllNodesSchedulable/" \
    -e "s/framework.WaitForSSHTunnels\b/e2enode.WaitForSSHTunnels/" \
    -e "s/framework.WorkItem\b/e2edebug.WorkItem/" \
    "$@"

for i in "$@"; do
    # Import all sub packages and let goimports figure out which of those
    # are redundant (= already imported) or not needed.
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2enode "k8s.io/kubernetes/test/e2e/framework/node"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2epod "k8s.io/kubernetes/test/e2e/framework/pod"' "$i"
    sed -i -e '/"k8s.io.kubernetes.test.e2e.framework"/a e2eproviders "k8s.io/kubernetes/test/e2e/framework/providers"' "$i"
    goimports -w "$i"
done
This commit is contained in:
Patrick Ohly
2022-09-08 16:04:17 +02:00
parent 92047da152
commit dfdf88d4fa
160 changed files with 822 additions and 715 deletions

View File

@@ -19,15 +19,17 @@ package windows
import (
"context"
"time"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
e2ekubelet "k8s.io/kubernetes/test/e2e/framework/kubelet"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
"time"
"github.com/onsi/ginkgo/v2"
)
@@ -43,10 +45,10 @@ var _ = SIGDescribe("[Feature:Windows] Cpu Resources [Serial]", func() {
ginkgo.It("should not be exceeded after waiting 2 minutes", func() {
ginkgo.By("Creating one pod with limit set to '0.5'")
podsDecimal := newCPUBurnPods(1, powershellImage, "0.5", "1Gi")
f.PodClient().CreateBatch(podsDecimal)
e2epod.NewPodClient(f).CreateBatch(podsDecimal)
ginkgo.By("Creating one pod with limit set to '500m'")
podsMilli := newCPUBurnPods(1, powershellImage, "500m", "1Gi")
f.PodClient().CreateBatch(podsMilli)
e2epod.NewPodClient(f).CreateBatch(podsMilli)
ginkgo.By("Waiting 2 minutes")
time.Sleep(2 * time.Minute)
ginkgo.By("Ensuring pods are still running")

View File

@@ -165,7 +165,7 @@ func createBatchPodWithRateControl(f *framework.Framework, pods []*v1.Pod, inter
createTimes := make(map[string]metav1.Time)
for _, pod := range pods {
createTimes[pod.ObjectMeta.Name] = metav1.Now()
go f.PodClient().Create(pod)
go e2epod.NewPodClient(f).Create(pod)
time.Sleep(interval)
}
return createTimes
@@ -273,7 +273,7 @@ func deletePodsSync(f *framework.Framework, pods []*v1.Pod) {
defer ginkgo.GinkgoRecover()
defer wg.Done()
err := f.PodClient().Delete(context.TODO(), pod.ObjectMeta.Name, *metav1.NewDeleteOptions(30))
err := e2epod.NewPodClient(f).Delete(context.TODO(), pod.ObjectMeta.Name, *metav1.NewDeleteOptions(30))
framework.ExpectNoError(err)
err = e2epod.WaitForPodToDisappear(f.ClientSet, f.Namespace.Name, pod.ObjectMeta.Name, labels.Everything(),

View File

@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
e2edaemonset "k8s.io/kubernetes/test/e2e/framework/daemonset"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
@@ -115,20 +116,20 @@ var _ = SIGDescribe("[Feature:GPUDevicePlugin] Device Plugin", func() {
//based on the windows version running the test.
dxdiagDirectxVersion := "DirectX Version: DirectX 12"
defaultNs := f.Namespace.Name
_, dxdiagDirectxVersionErr := framework.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagDirectxVersion, time.Minute)
_, dxdiagDirectxVersionErr := e2eoutput.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagDirectxVersion, time.Minute)
framework.ExpectNoError(dxdiagDirectxVersionErr, "failed: didn't find directX version dxdiag output.")
dxdiagDdiVersion := "DDI Version: 12"
_, dxdiagDdiVersionErr := framework.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagDdiVersion, time.Minute)
_, dxdiagDdiVersionErr := e2eoutput.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagDdiVersion, time.Minute)
framework.ExpectNoError(dxdiagDdiVersionErr, "failed: didn't find DDI version in dxdiag output.")
dxdiagVendorID := "Vendor ID: 0x"
_, dxdiagVendorIDErr := framework.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagVendorID, time.Minute)
_, dxdiagVendorIDErr := e2eoutput.LookForStringInPodExec(defaultNs, windowsPod.Name, dxdiagCommand, dxdiagVendorID, time.Minute)
framework.ExpectNoError(dxdiagVendorIDErr, "failed: didn't find vendorID in dxdiag output.")
envVarCommand := []string{"cmd.exe", "/c", "set", "DIRECTX_GPU_Name"}
envVarDirectxGpuName := "DIRECTX_GPU_Name="
_, envVarDirectxGpuNameErr := framework.LookForStringInPodExec(defaultNs, windowsPod.Name, envVarCommand, envVarDirectxGpuName, time.Minute)
_, envVarDirectxGpuNameErr := e2eoutput.LookForStringInPodExec(defaultNs, windowsPod.Name, envVarCommand, envVarDirectxGpuName, time.Minute)
framework.ExpectNoError(envVarDirectxGpuNameErr, "failed: didn't find expected environment variable.")
})
})

View File

@@ -77,7 +77,7 @@ var _ = SIGDescribe("[Feature:Windows] DNS", func() {
// This isn't the best 'test' but it is a great diagnostic, see later test for the 'real' test.
ginkgo.By("Calling ipconfig to get debugging info for this pod's DNS and confirm that a dns server 1.1.1.1 can be injected, along with ")
cmd := []string{"ipconfig", "/all"}
stdout, _, err := f.ExecWithOptions(framework.ExecOptions{
stdout, _, err := e2epod.ExecWithOptions(f, e2epod.ExecOptions{
Command: cmd,
Namespace: f.Namespace.Name,
PodName: testPod.Name,
@@ -102,7 +102,7 @@ var _ = SIGDescribe("[Feature:Windows] DNS", func() {
// TODO @jayunit100 add ResolveHost to agn images
cmd = []string{"curl.exe", "-k", "https://kubernetezzzzzzzz:443"}
stdout, _, err = f.ExecWithOptions(framework.ExecOptions{
stdout, _, err = e2epod.ExecWithOptions(f, e2epod.ExecOptions{
Command: cmd,
Namespace: f.Namespace.Name,
PodName: testPod.Name,
@@ -117,7 +117,7 @@ var _ = SIGDescribe("[Feature:Windows] DNS", func() {
ginkgo.By("Verifying that injected dns records for 'kubernetes' resolve to the valid ip address")
cmd = []string{"curl.exe", "-k", "https://kubernetes:443"}
stdout, _, err = f.ExecWithOptions(framework.ExecOptions{
stdout, _, err = e2epod.ExecWithOptions(f, e2epod.ExecOptions{
Command: cmd,
Namespace: f.Namespace.Name,
PodName: testPod.Name,

View File

@@ -57,6 +57,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework"
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
imageutils "k8s.io/kubernetes/test/utils/image"
@@ -288,7 +289,7 @@ func retrieveCRDManifestFileContents(f *framework.Framework, node v1.Node) strin
},
},
}
f.PodClient().CreateSync(pod)
e2epod.NewPodClient(f).CreateSync(pod)
output, err := runKubectlExecInNamespace(f.Namespace.Name, podName, "cmd", "/S", "/C", fmt.Sprintf("type %s", gmsaCrdManifestPath))
if err != nil {
@@ -311,10 +312,10 @@ func deployGmsaWebhook(f *framework.Framework) (func(), error) {
// regardless of whether the deployment succeeded, let's do a best effort at cleanup
cleanUpFunc := func() {
framework.Logf("Best effort clean up of the webhook:\n")
stdout, err := framework.RunKubectl("", "delete", "CustomResourceDefinition", "gmsacredentialspecs.windows.k8s.io")
stdout, err := e2ekubectl.RunKubectl("", "delete", "CustomResourceDefinition", "gmsacredentialspecs.windows.k8s.io")
framework.Logf("stdout:%s\nerror:%s", stdout, err)
stdout, err = framework.RunKubectl("", "delete", "CertificateSigningRequest", fmt.Sprintf("%s.%s", webHookName, webHookNamespace))
stdout, err = e2ekubectl.RunKubectl("", "delete", "CertificateSigningRequest", fmt.Sprintf("%s.%s", webHookName, webHookNamespace))
framework.Logf("stdout:%s\nerror:%s", stdout, err)
stdout, err = runKubectlExecInNamespace(deployerNamespace, deployerName, "--", "kubectl", "delete", "-f", "/manifests.yml")
@@ -362,7 +363,7 @@ func deployGmsaWebhook(f *framework.Framework) (func(), error) {
},
},
}
f.PodClient().CreateSync(pod)
e2epod.NewPodClient(f).CreateSync(pod)
// Wait for the Webhook deployment to become ready. The deployer pod takes a few seconds to initialize and create resources
err := waitForDeployment(func() (*appsv1.Deployment, error) {
@@ -395,7 +396,7 @@ func createGmsaCustomResource(ns string, crdManifestContents string) (func(), er
defer tempFile.Close()
cleanUpFunc = func() {
framework.RunKubectl(ns, "delete", "--filename", tempFile.Name())
e2ekubectl.RunKubectl(ns, "delete", "--filename", tempFile.Name())
os.Remove(tempFile.Name())
}
@@ -405,7 +406,7 @@ func createGmsaCustomResource(ns string, crdManifestContents string) (func(), er
return cleanUpFunc, err
}
output, err := framework.RunKubectl(ns, "apply", "--filename", tempFile.Name())
output, err := e2ekubectl.RunKubectl(ns, "apply", "--filename", tempFile.Name())
if err != nil {
err = fmt.Errorf("unable to create custom resource, output:\n%s: %w", output, err)
}
@@ -535,14 +536,14 @@ func createPodWithGmsa(f *framework.Framework, serviceAccountName string) string
},
},
}
f.PodClient().CreateSync(pod)
e2epod.NewPodClient(f).CreateSync(pod)
return podName
}
func runKubectlExecInNamespace(namespace string, args ...string) (string, error) {
namespaceOption := fmt.Sprintf("--namespace=%s", namespace)
return framework.RunKubectl(namespace, append([]string{"exec", namespaceOption}, args...)...)
return e2ekubectl.RunKubectl(namespace, append([]string{"exec", namespaceOption}, args...)...)
}
func getGmsaDomainIP(f *framework.Framework, podName string) string {

View File

@@ -29,6 +29,8 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/test/e2e/framework"
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
@@ -92,7 +94,7 @@ var _ = SIGDescribe("[Feature:Windows] GMSA Kubelet [Slow]", func() {
}
ginkgo.By("creating a pod with correct GMSA specs")
f.PodClient().CreateSync(pod)
e2epod.NewPodClient(f).CreateSync(pod)
ginkgo.By("checking the domain reported by nltest in the containers")
namespaceOption := fmt.Sprintf("--namespace=%s", f.Namespace.Name)
@@ -110,7 +112,7 @@ var _ = SIGDescribe("[Feature:Windows] GMSA Kubelet [Slow]", func() {
// note that the "eventually" part seems to be needed to account for the fact that powershell containers
// are a bit slow to become responsive, even when docker reports them as running.
gomega.Eventually(func() bool {
output, err = framework.RunKubectl(f.Namespace.Name, "exec", namespaceOption, podName, containerOption, "--", "nltest", "/PARENTDOMAIN")
output, err = e2ekubectl.RunKubectl(f.Namespace.Name, "exec", namespaceOption, podName, containerOption, "--", "nltest", "/PARENTDOMAIN")
return err == nil
}, 1*time.Minute, 1*time.Second).Should(gomega.BeTrue())

View File

@@ -122,10 +122,10 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
},
}
f.PodClient().Create(pod)
e2epod.NewPodClient(f).Create(pod)
ginkgo.By("Waiting for pod to run")
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Then ensuring pod finished running successfully")
p, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(
@@ -174,10 +174,10 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
},
}
f.PodClient().Create(pod)
e2epod.NewPodClient(f).Create(pod)
ginkgo.By("Waiting for pod to run")
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Then ensuring pod finished running successfully")
p, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(
@@ -412,10 +412,10 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
},
},
}
f.PodClient().Create(pod)
e2epod.NewPodClient(f).Create(pod)
ginkgo.By(fmt.Sprintf("Waiting for pod '%s' to run", podName))
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Then ensuring pod finished running successfully")
p, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(
@@ -487,10 +487,10 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
podAndContainerName := "host-process-volume-mounts"
pod := makeTestPodWithVolumeMounts(podAndContainerName)
f.PodClient().Create(pod)
e2epod.NewPodClient(f).Create(pod)
ginkgo.By("Waiting for pod to run")
f.PodClient().WaitForFinish(podAndContainerName, 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish(podAndContainerName, 3*time.Minute)
logs, err := e2epod.GetPodLogs(f.ClientSet, ns.Name, podAndContainerName, podAndContainerName)
framework.ExpectNoError(err, "Error getting pod logs")
@@ -552,8 +552,8 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
},
}
f.PodClient().Create(pod)
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).Create(pod)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Scheduling a pod with a HostProcess container that will fail")
podName = "host-process-metrics-pod-failing-container"
@@ -581,8 +581,8 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
},
}
f.PodClient().Create(pod)
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).Create(pod)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Getting subsequent kubelet metrics values")

View File

@@ -23,6 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
admissionapi "k8s.io/pod-security-admission/api"
@@ -56,13 +57,13 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
linuxPod := createTestPod(f, linuxBusyBoxImage, linuxOS)
ginkgo.By("creating a linux pod and waiting for it to be running")
linuxPod = f.PodClient().CreateSync(linuxPod)
linuxPod = e2epod.NewPodClient(f).CreateSync(linuxPod)
windowsPod := createTestPod(f, windowsBusyBoximage, windowsOS)
windowsPod.Spec.Containers[0].Args = []string{"test-webserver"}
ginkgo.By("creating a windows pod and waiting for it to be running")
windowsPod = f.PodClient().CreateSync(windowsPod)
windowsPod = e2epod.NewPodClient(f).CreateSync(windowsPod)
ginkgo.By("verifying pod internal connectivity to the cluster dataplane")
@@ -77,7 +78,7 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
ginkgo.It("should provide Internet connection for Linux containers using DNS [Feature:Networking-DNS]", func() {
linuxPod := createTestPod(f, linuxBusyBoxImage, linuxOS)
ginkgo.By("creating a linux pod and waiting for it to be running")
linuxPod = f.PodClient().CreateSync(linuxPod)
linuxPod = e2epod.NewPodClient(f).CreateSync(linuxPod)
ginkgo.By("verifying pod external connectivity to the internet")
@@ -88,7 +89,7 @@ var _ = SIGDescribe("Hybrid cluster network", func() {
ginkgo.It("should provide Internet connection for Windows containers using DNS [Feature:Networking-DNS]", func() {
windowsPod := createTestPod(f, windowsBusyBoximage, windowsOS)
ginkgo.By("creating a windows pod and waiting for it to be running")
windowsPod = f.PodClient().CreateSync(windowsPod)
windowsPod = e2epod.NewPodClient(f).CreateSync(windowsPod)
ginkgo.By("verifying pod external connectivity to the internet")
@@ -109,7 +110,7 @@ func assertConsistentConnectivity(f *framework.Framework, podName string, os str
connChecker := func() error {
ginkgo.By(fmt.Sprintf("checking connectivity of %s-container in %s", os, podName))
// TODO, we should be retrying this similar to what is done in DialFromNode, in the test/e2e/networking/networking.go tests
stdout, stderr, err := f.ExecCommandInContainerWithFullOutput(podName, os+"-container", cmd...)
stdout, stderr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, os+"-container", cmd...)
if err != nil {
framework.Logf("Encountered error while running command: %v.\nStdout: %s\nStderr: %s\nErr: %v", cmd, stdout, stderr, err)
}

View File

@@ -54,7 +54,7 @@ var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats [Serial]", func() {
ginkgo.By("Scheduling 10 pods")
powershellImage := imageutils.GetConfig(imageutils.BusyBox)
pods := newKubeletStatsTestPods(10, powershellImage, targetNode.Name)
f.PodClient().CreateBatch(pods)
e2epod.NewPodClient(f).CreateBatch(pods)
ginkgo.By("Waiting up to 3 minutes for pods to be running")
timeout := 3 * time.Minute
@@ -144,7 +144,7 @@ var _ = SIGDescribe("[Feature:Windows] Kubelet-Stats", func() {
ginkgo.By("Scheduling 3 pods")
powershellImage := imageutils.GetConfig(imageutils.BusyBox)
pods := newKubeletStatsTestPods(3, powershellImage, targetNode.Name)
f.PodClient().CreateBatch(pods)
e2epod.NewPodClient(f).CreateBatch(pods)
ginkgo.By("Waiting up to 3 minutes for pods to be running")
timeout := 3 * time.Minute

View File

@@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
@@ -73,7 +74,7 @@ var _ = SIGDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
}
agnPod.Spec.Containers[0].Args = []string{"test-webserver"}
ginkgo.By("creating a windows pod and waiting for it to be running")
agnPod = f.PodClient().CreateSync(agnPod)
agnPod = e2epod.NewPodClient(f).CreateSync(agnPod)
// Create Linux pod to ping the windows pod
linuxBusyBoxImage := imageutils.GetE2EImage(imageutils.Nginx)
@@ -106,7 +107,7 @@ var _ = SIGDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
},
}
ginkgo.By("Waiting for the Linux pod to run")
nginxPod = f.PodClient().CreateSync(nginxPod)
nginxPod = e2epod.NewPodClient(f).CreateSync(nginxPod)
ginkgo.By("checking connectivity to 8.8.8.8 53 (google.com) from Linux")
assertConsistentConnectivity(f, nginxPod.ObjectMeta.Name, "linux", linuxCheck("8.8.8.8", 53))
@@ -155,10 +156,10 @@ var _ = SIGDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
},
}
f.PodClient().Create(pod)
e2epod.NewPodClient(f).Create(pod)
ginkgo.By("Waiting for pod to run")
f.PodClient().WaitForFinish(podName, 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish(podName, 3*time.Minute)
ginkgo.By("Then ensuring pod finished running successfully")
p, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(
@@ -238,10 +239,10 @@ var _ = SIGDescribe("[Feature:Windows] [Excluded:WindowsDocker] [MinimumKubeletV
},
}
f.PodClient().Create(checkPod)
e2epod.NewPodClient(f).Create(checkPod)
ginkgo.By("Waiting for pod to run")
f.PodClient().WaitForFinish("check-reboot-pod", 3*time.Minute)
e2epod.NewPodClient(f).WaitForFinish("check-reboot-pod", 3*time.Minute)
ginkgo.By("Then ensuring pod finished running successfully")
p, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(

View File

@@ -32,6 +32,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eoutput "k8s.io/kubernetes/test/e2e/framework/pod/output"
testutils "k8s.io/kubernetes/test/utils"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
@@ -46,15 +47,15 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
ginkgo.It("should be able create pods and run containers with a given username", func() {
ginkgo.By("Creating 2 pods: 1 with the default user, and one with a custom one.")
podDefault := runAsUserNamePod(nil)
f.TestContainerOutput("check default user", podDefault, 0, []string{"ContainerUser"})
e2eoutput.TestContainerOutput(f, "check default user", podDefault, 0, []string{"ContainerUser"})
podUserName := runAsUserNamePod(toPtr("ContainerAdministrator"))
f.TestContainerOutput("check set user", podUserName, 0, []string{"ContainerAdministrator"})
e2eoutput.TestContainerOutput(f, "check set user", podUserName, 0, []string{"ContainerAdministrator"})
})
ginkgo.It("should not be able to create pods with unknown usernames at Pod level", func() {
ginkgo.By("Creating a pod with an invalid username")
podInvalid := f.PodClient().Create(runAsUserNamePod(toPtr("FooLish")))
podInvalid := e2epod.NewPodClient(f).Create(runAsUserNamePod(toPtr("FooLish")))
failedSandboxEventSelector := fields.Set{
"involvedObject.kind": "Pod",
@@ -82,7 +83,7 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
}
framework.Logf("No Sandbox error found. Looking for failure in workload pods")
pod, err := f.PodClient().Get(context.Background(), podInvalid.Name, metav1.GetOptions{})
pod, err := e2epod.NewPodClient(f).Get(context.Background(), podInvalid.Name, metav1.GetOptions{})
if err != nil {
framework.Logf("Error retrieving pod: %s", err)
return false
@@ -103,12 +104,12 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
ginkgo.By("Creating a pod with an invalid username at container level and pod running as ContainerUser")
p := runAsUserNamePod(toPtr("FooLish"))
p.Spec.SecurityContext.WindowsOptions.RunAsUserName = toPtr("ContainerUser")
podInvalid := f.PodClient().Create(p)
podInvalid := e2epod.NewPodClient(f).Create(p)
framework.Logf("Waiting for pod %s to enter the error state.", podInvalid.Name)
framework.ExpectNoError(e2epod.WaitForPodTerminatedInNamespace(f.ClientSet, podInvalid.Name, "", f.Namespace.Name))
podInvalid, _ = f.PodClient().Get(context.TODO(), podInvalid.Name, metav1.GetOptions{})
podInvalid, _ = e2epod.NewPodClient(f).Get(context.TODO(), podInvalid.Name, metav1.GetOptions{})
podTerminatedReason := testutils.TerminatedContainers(podInvalid)[runAsUserNameContainerName]
if podTerminatedReason != "ContainerCannotRun" && podTerminatedReason != "StartError" {
framework.Failf("The container terminated reason was supposed to be: 'ContainerCannotRun' or 'StartError', not: '%q'", podTerminatedReason)
@@ -126,8 +127,8 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
Command: []string{"cmd", "/S", "/C", "echo %username%"},
})
f.TestContainerOutput("check overridden username", pod, 0, []string{"ContainerUser"})
f.TestContainerOutput("check pod SecurityContext username", pod, 1, []string{"ContainerAdministrator"})
e2eoutput.TestContainerOutput(f, "check overridden username", pod, 0, []string{"ContainerUser"})
e2eoutput.TestContainerOutput(f, "check pod SecurityContext username", pod, 1, []string{"ContainerAdministrator"})
})
ginkgo.It("should ignore Linux Specific SecurityContext if set", func() {
@@ -164,7 +165,7 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
framework.ExpectNoError(err, "Error creating pod")
ginkgo.By("Waiting for pod to finish")
event, err := f.PodClient().WaitForErrorEventOrSuccess(podInvalid)
event, err := e2epod.NewPodClient(f).WaitForErrorEventOrSuccess(podInvalid)
framework.ExpectNoError(err)
framework.ExpectNotEqual(event, nil, "event should not be empty")
framework.Logf("Got event: %v", event)
@@ -182,7 +183,7 @@ var _ = SIGDescribe("[Feature:Windows] SecurityContext", func() {
framework.ExpectNoError(err, "Error creating pod")
ginkgo.By("Waiting for pod to finish")
event, err := f.PodClient().WaitForErrorEventOrSuccess(podInvalid)
event, err := e2epod.NewPodClient(f).WaitForErrorEventOrSuccess(podInvalid)
framework.ExpectNoError(err)
framework.ExpectNotEqual(event, nil, "event should not be empty")
framework.Logf("Got event: %v", event)

View File

@@ -26,6 +26,7 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
admissionapi "k8s.io/pod-security-admission/api"
@@ -73,7 +74,7 @@ var _ = SIGDescribe("Services", func() {
//using hybrid_network methods
ginkgo.By("creating Windows testing Pod")
testPod := createTestPod(f, windowsBusyBoximage, windowsOS)
testPod = f.PodClient().CreateSync(testPod)
testPod = e2epod.NewPodClient(f).CreateSync(testPod)
ginkgo.By("verifying that pod has the correct nodeSelector")
// Admission controllers may sometimes do the wrong thing

View File

@@ -23,6 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
@@ -96,14 +97,14 @@ func doReadOnlyTest(f *framework.Framework, source v1.VolumeSource, volumePath s
"kubernetes.io/os": "windows",
}
pod = f.PodClient().CreateSync(pod)
pod = e2epod.NewPodClient(f).CreateSync(pod)
ginkgo.By("verifying that pod has the correct nodeSelector")
framework.ExpectEqual(pod.Spec.NodeSelector["kubernetes.io/os"], "windows")
cmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}
ginkgo.By("verifying that pod will get an error when writing to a volume that is readonly")
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)
_, stderr, _ := e2epod.ExecCommandInContainerWithFullOutput(f, podName, containerName, cmd...)
framework.ExpectEqual(stderr, "Access is denied.")
}
@@ -130,24 +131,24 @@ func doReadWriteReadOnlyTest(f *framework.Framework, source v1.VolumeSource, vol
}
pod.Spec.Containers = append(pod.Spec.Containers, rwcontainer)
pod = f.PodClient().CreateSync(pod)
pod = e2epod.NewPodClient(f).CreateSync(pod)
ginkgo.By("verifying that pod has the correct nodeSelector")
framework.ExpectEqual(pod.Spec.NodeSelector["kubernetes.io/os"], "windows")
ginkgo.By("verifying that pod can write to a volume with read/write access")
writecmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}
stdoutRW, stderrRW, errRW := f.ExecCommandInContainerWithFullOutput(podName, rwcontainerName, writecmd...)
stdoutRW, stderrRW, errRW := e2epod.ExecCommandInContainerWithFullOutput(f, podName, rwcontainerName, writecmd...)
msg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", writecmd, stdoutRW, stderrRW)
framework.ExpectNoError(errRW, msg)
ginkgo.By("verifying that pod will get an error when writing to a volume that is readonly")
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, writecmd...)
_, stderr, _ := e2epod.ExecCommandInContainerWithFullOutput(f, podName, containerName, writecmd...)
framework.ExpectEqual(stderr, "Access is denied.")
ginkgo.By("verifying that pod can read from a volume that is readonly")
readcmd := []string{"cmd", "/c", "type", filePath}
readout, readerr, err := f.ExecCommandInContainerWithFullOutput(podName, containerName, readcmd...)
readout, readerr, err := e2epod.ExecCommandInContainerWithFullOutput(f, podName, containerName, readcmd...)
readmsg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", readcmd, readout, readerr)
framework.ExpectEqual(readout, "windows-volume-test")
framework.ExpectNoError(err, readmsg)