mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
code comments
- what the test is doing - how the test is set up - subsections of the test setup additional output - print time spent getting ready to run proxy attempts - number of test cases - multiple attempts of each test case - how many total proxying attempts will be made - fast path output now has numerical identity of attempt like error output - error output has time taken and http status like fast path output batching runs - run groups of test cases vs starting all 34*20=680 proxy attempts at the same time. - don't wait between starting proxy attempts anymore. proxy e2e changes - disable the client side rate limiter - use `By` construct of ginkgo for inline `STEP` logging - move the waitGroup add outside of the loop
This commit is contained in:
parent
b38271b6d5
commit
b50e986fad
@ -53,7 +53,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func proxyContext(version string) {
|
func proxyContext(version string) {
|
||||||
f := framework.NewDefaultFramework("proxy")
|
options := framework.FrameworkOptions{
|
||||||
|
ClientQPS: -1.0,
|
||||||
|
}
|
||||||
|
f := framework.NewFramework("proxy", options, nil)
|
||||||
prefix := "/api/" + version
|
prefix := "/api/" + version
|
||||||
|
|
||||||
// Port here has to be kept in sync with default kubelet port.
|
// Port here has to be kept in sync with default kubelet port.
|
||||||
@ -65,7 +68,10 @@ func proxyContext(version string) {
|
|||||||
It("should proxy logs on node using proxy subresource [Conformance]", func() { nodeProxyTest(f, prefix+"/nodes/", "/proxy/logs/") })
|
It("should proxy logs on node using proxy subresource [Conformance]", func() { nodeProxyTest(f, prefix+"/nodes/", "/proxy/logs/") })
|
||||||
It("should proxy to cadvisor using proxy subresource [Conformance]", func() { nodeProxyTest(f, prefix+"/nodes/", ":4194/proxy/containers/") })
|
It("should proxy to cadvisor using proxy subresource [Conformance]", func() { nodeProxyTest(f, prefix+"/nodes/", ":4194/proxy/containers/") })
|
||||||
|
|
||||||
|
// using the porter image to serve content, access the content
|
||||||
|
// (of multiple pods?) from multiple (endpoints/services?)
|
||||||
It("should proxy through a service and a pod [Conformance]", func() {
|
It("should proxy through a service and a pod [Conformance]", func() {
|
||||||
|
start := time.Now()
|
||||||
labels := map[string]string{"proxy-service-target": "true"}
|
labels := map[string]string{"proxy-service-target": "true"}
|
||||||
service, err := f.Client.Services(f.Namespace.Name).Create(&api.Service{
|
service, err := f.Client.Services(f.Namespace.Name).Create(&api.Service{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
@ -105,7 +111,10 @@ func proxyContext(version string) {
|
|||||||
}
|
}
|
||||||
}(service.Name)
|
}(service.Name)
|
||||||
|
|
||||||
// Make an RC with a single pod.
|
// Make an RC with a single pod. The 'porter' image is
|
||||||
|
// a simple server which serves the values of the
|
||||||
|
// environmental variables below.
|
||||||
|
By("starting an echo server on multiple ports")
|
||||||
pods := []*api.Pod{}
|
pods := []*api.Pod{}
|
||||||
cfg := framework.RCConfig{
|
cfg := framework.RCConfig{
|
||||||
Client: f.Client,
|
Client: f.Client,
|
||||||
@ -149,6 +158,7 @@ func proxyContext(version string) {
|
|||||||
|
|
||||||
Expect(f.WaitForAnEndpoint(service.Name)).NotTo(HaveOccurred())
|
Expect(f.WaitForAnEndpoint(service.Name)).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
// table constructors
|
||||||
// Try proxying through the service and directly to through the pod.
|
// Try proxying through the service and directly to through the pod.
|
||||||
svcProxyURL := func(scheme, port string) string {
|
svcProxyURL := func(scheme, port string) string {
|
||||||
return prefix + "/proxy/namespaces/" + f.Namespace.Name + "/services/" + net.JoinSchemeNamePort(scheme, service.Name, port)
|
return prefix + "/proxy/namespaces/" + f.Namespace.Name + "/services/" + net.JoinSchemeNamePort(scheme, service.Name, port)
|
||||||
@ -162,6 +172,8 @@ func proxyContext(version string) {
|
|||||||
subresourcePodProxyURL := func(scheme, port string) string {
|
subresourcePodProxyURL := func(scheme, port string) string {
|
||||||
return prefix + "/namespaces/" + f.Namespace.Name + "/pods/" + net.JoinSchemeNamePort(scheme, pods[0].Name, port) + "/proxy"
|
return prefix + "/namespaces/" + f.Namespace.Name + "/pods/" + net.JoinSchemeNamePort(scheme, pods[0].Name, port) + "/proxy"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// construct the table
|
||||||
expectations := map[string]string{
|
expectations := map[string]string{
|
||||||
svcProxyURL("", "portname1") + "/": "foo",
|
svcProxyURL("", "portname1") + "/": "foo",
|
||||||
svcProxyURL("", "80") + "/": "foo",
|
svcProxyURL("", "80") + "/": "foo",
|
||||||
@ -218,15 +230,24 @@ func proxyContext(version string) {
|
|||||||
defer errLock.Unlock()
|
defer errLock.Unlock()
|
||||||
errs = append(errs, s)
|
errs = append(errs, s)
|
||||||
}
|
}
|
||||||
|
d := time.Since(start)
|
||||||
|
framework.Logf("setup took %v, starting test cases", d)
|
||||||
|
numberTestCases := len(expectations)
|
||||||
|
totalAttempts := numberTestCases * proxyAttempts
|
||||||
|
By(fmt.Sprintf("running %v cases, %v attempts per case, %v total attempts", numberTestCases, proxyAttempts, totalAttempts))
|
||||||
|
|
||||||
for i := 0; i < proxyAttempts; i++ {
|
for i := 0; i < proxyAttempts; i++ {
|
||||||
|
wg.Add(numberTestCases)
|
||||||
for path, val := range expectations {
|
for path, val := range expectations {
|
||||||
wg.Add(1)
|
|
||||||
go func(i int, path, val string) {
|
go func(i int, path, val string) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
body, status, d, err := doProxy(f, path)
|
// this runs the test case
|
||||||
|
body, status, d, err := doProxy(f, path, i)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if serr, ok := err.(*errors.StatusError); ok {
|
if serr, ok := err.(*errors.StatusError); ok {
|
||||||
recordError(fmt.Sprintf("%v: path %v gave status error: %+v", i, path, serr.Status()))
|
recordError(fmt.Sprintf("%v (%v; %v): path %v gave status error: %+v",
|
||||||
|
i, status, d, path, serr.Status()))
|
||||||
} else {
|
} else {
|
||||||
recordError(fmt.Sprintf("%v: path %v gave error: %v", i, path, err))
|
recordError(fmt.Sprintf("%v: path %v gave error: %v", i, path, err))
|
||||||
}
|
}
|
||||||
@ -242,11 +263,9 @@ func proxyContext(version string) {
|
|||||||
recordError(fmt.Sprintf("%v: path %v took %v > %v", i, path, d, proxyHTTPCallTimeout))
|
recordError(fmt.Sprintf("%v: path %v took %v > %v", i, path, d, proxyHTTPCallTimeout))
|
||||||
}
|
}
|
||||||
}(i, path, val)
|
}(i, path, val)
|
||||||
// default QPS is 5
|
|
||||||
time.Sleep(200 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
if len(errs) != 0 {
|
if len(errs) != 0 {
|
||||||
body, err := f.Client.Pods(f.Namespace.Name).GetLogs(pods[0].Name, &api.PodLogOptions{}).Do().Raw()
|
body, err := f.Client.Pods(f.Namespace.Name).GetLogs(pods[0].Name, &api.PodLogOptions{}).Do().Raw()
|
||||||
@ -261,7 +280,7 @@ func proxyContext(version string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func doProxy(f *framework.Framework, path string) (body []byte, statusCode int, d time.Duration, err error) {
|
func doProxy(f *framework.Framework, path string, i int) (body []byte, statusCode int, d time.Duration, err error) {
|
||||||
// About all of the proxy accesses in this file:
|
// About all of the proxy accesses in this file:
|
||||||
// * AbsPath is used because it preserves the trailing '/'.
|
// * AbsPath is used because it preserves the trailing '/'.
|
||||||
// * Do().Raw() is used (instead of DoRaw()) because it will turn an
|
// * Do().Raw() is used (instead of DoRaw()) because it will turn an
|
||||||
@ -272,7 +291,7 @@ func doProxy(f *framework.Framework, path string) (body []byte, statusCode int,
|
|||||||
body, err = f.Client.Get().AbsPath(path).Do().StatusCode(&statusCode).Raw()
|
body, err = f.Client.Get().AbsPath(path).Do().StatusCode(&statusCode).Raw()
|
||||||
d = time.Since(start)
|
d = time.Since(start)
|
||||||
if len(body) > 0 {
|
if len(body) > 0 {
|
||||||
framework.Logf("%v: %s (%v; %v)", path, truncate(body, maxDisplayBodyLen), statusCode, d)
|
framework.Logf("(%v) %v: %s (%v; %v)", i, path, truncate(body, maxDisplayBodyLen), statusCode, d)
|
||||||
} else {
|
} else {
|
||||||
framework.Logf("%v: %s (%v; %v)", path, "no body", statusCode, d)
|
framework.Logf("%v: %s (%v; %v)", path, "no body", statusCode, d)
|
||||||
}
|
}
|
||||||
@ -304,7 +323,7 @@ func nodeProxyTest(f *framework.Framework, prefix, nodeDest string) {
|
|||||||
// not reaching Kubelet issue is debugged.
|
// not reaching Kubelet issue is debugged.
|
||||||
serviceUnavailableErrors := 0
|
serviceUnavailableErrors := 0
|
||||||
for i := 0; i < proxyAttempts; i++ {
|
for i := 0; i < proxyAttempts; i++ {
|
||||||
_, status, d, err := doProxy(f, prefix+node+nodeDest)
|
_, status, d, err := doProxy(f, prefix+node+nodeDest, i)
|
||||||
if status == http.StatusServiceUnavailable {
|
if status == http.StatusServiceUnavailable {
|
||||||
framework.Logf("Failed proxying node logs due to service unavailable: %v", err)
|
framework.Logf("Failed proxying node logs due to service unavailable: %v", err)
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user