mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Split minion
This commit is contained in:
@@ -23,9 +23,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -535,52 +533,3 @@ func TestSyncCreateTimeout(t *testing.T) {
|
||||
t.Errorf("Unexpected status: %d, Expected: %d, %#v", response.StatusCode, 202, response)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMinionTransport(t *testing.T) {
|
||||
content := string(`<pre><a href="kubelet.log">kubelet.log</a><a href="google.log">google.log</a></pre>`)
|
||||
transport := &minionTransport{}
|
||||
|
||||
// Test /logs/
|
||||
request := &http.Request{
|
||||
Method: "GET",
|
||||
URL: &url.URL{
|
||||
Scheme: "http",
|
||||
Host: "minion1:10250",
|
||||
Path: "/logs/",
|
||||
},
|
||||
}
|
||||
response := &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(strings.NewReader(content)),
|
||||
Close: true,
|
||||
}
|
||||
updated_resp, _ := transport.ProcessResponse(request, response)
|
||||
body, _ := ioutil.ReadAll(updated_resp.Body)
|
||||
expected := string(`<pre><a href="/proxy/minion/minion1:10250/logs/kubelet.log">kubelet.log</a><a href="/proxy/minion/minion1:10250/logs/google.log">google.log</a></pre>`)
|
||||
if !strings.Contains(string(body), expected) {
|
||||
t.Errorf("Received wrong content: %s", string(body))
|
||||
}
|
||||
|
||||
// Test subdir under /logs/
|
||||
request = &http.Request{
|
||||
Method: "GET",
|
||||
URL: &url.URL{
|
||||
Scheme: "http",
|
||||
Host: "minion1:8080",
|
||||
Path: "/whatever/apt/",
|
||||
},
|
||||
}
|
||||
response = &http.Response{
|
||||
Status: "200 OK",
|
||||
StatusCode: http.StatusOK,
|
||||
Body: ioutil.NopCloser(strings.NewReader(content)),
|
||||
Close: true,
|
||||
}
|
||||
updated_resp, _ = transport.ProcessResponse(request, response)
|
||||
body, _ = ioutil.ReadAll(updated_resp.Body)
|
||||
expected = string(`<pre><a href="/proxy/minion/minion1:8080/whatever/apt/kubelet.log">kubelet.log</a><a href="/proxy/minion/minion1:8080/whatever/apt/google.log">google.log</a></pre>`)
|
||||
if !strings.Contains(string(body), expected) {
|
||||
t.Errorf("Received wrong content: %s", string(body))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user