Merge pull request #8278 from lavalamp/no-ro-nettest

Fix networking test
This commit is contained in:
Victor Marmol 2015-05-14 18:26:15 -07:00
commit 7cc42209f5
4 changed files with 29 additions and 13 deletions

View File

@ -1,7 +1,7 @@
all: push all: push
# Set this to the *next* version to prevent accidentally overwriting the existing image. # Set this to the *next* version to prevent accidentally overwriting the existing image.
TAG = 1.4 TAG = 1.5
webserver: webserver.go webserver: webserver.go
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./webserver.go CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./webserver.go

View File

@ -8,7 +8,7 @@
} }
}, },
"spec": { "spec": {
"replicas": 8, "replicas": 2,
"selector": { "selector": {
"name": "nettest" "name": "nettest"
}, },
@ -22,9 +22,13 @@
"containers": [ "containers": [
{ {
"name": "webserver", "name": "webserver",
"image": "gcr.io/google_containers/nettest:1.1", "image": "gcr.io/google_containers/nettest:1.4",
"command": [ "imagePullPolicy": "Always",
"-service=nettest" "args": [
"-service=nettest",
"-port=8080",
"-namespace=default",
"-peers=2"
], ],
"ports": [ "ports": [
{ {

View File

@ -37,13 +37,12 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"math/rand" "math/rand"
"net"
"net/http" "net/http"
"net/url"
"os" "os"
"sync" "sync"
"time" "time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
) )
@ -203,12 +202,25 @@ func main() {
// Find all sibling pods in the service and post to their /write handler. // Find all sibling pods in the service and post to their /write handler.
func contactOthers(state *State) { func contactOthers(state *State) {
defer state.doneContactingPeers() defer state.doneContactingPeers()
masterRO := url.URL{ token, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/token")
Scheme: "http", if err != nil {
Host: os.Getenv("KUBERNETES_RO_SERVICE_HOST") + ":" + os.Getenv("KUBERNETES_RO_SERVICE_PORT"), log.Fatalf("Unable to read service account token: %v", err)
Path: "/api/" + latest.Version, }
cc := client.Config{
Host: "https://" + net.JoinHostPort(os.Getenv("KUBERNETES_SERVICE_HOST"), os.Getenv("KUBERNETES_SERVICE_PORT")),
Version: "v1beta3",
BearerToken: string(token),
Insecure: true, // TOOD: package certs along with the token
}
client, err := client.New(&cc)
if err != nil {
log.Fatalf("Unable to create client:\nconfig: %#v\nerror: %v\n", err)
}
if v, err := client.ServerVersion(); err != nil {
log.Fatalf("Unable to get server version: %v\n", err)
} else {
log.Printf("Server version: %#v\n", v)
} }
client := &client.Client{client.NewRESTClient(&masterRO, latest.Version, latest.Codec, false, 5, 10)}
// Do this repeatedly, in case there's some propagation delay with getting // Do this repeatedly, in case there's some propagation delay with getting
// newly started pods into the endpoints list. // newly started pods into the endpoints list.

View File

@ -55,7 +55,7 @@ func LaunchNetTestPodPerNode(nodes *api.NodeList, name string, c *client.Client,
Containers: []api.Container{ Containers: []api.Container{
{ {
Name: "webserver", Name: "webserver",
Image: "gcr.io/google_containers/nettest:1.3", Image: "gcr.io/google_containers/nettest:1.4",
Args: []string{ Args: []string{
"-service=" + name, "-service=" + name,
//peers >= totalPods should be asserted by the container. //peers >= totalPods should be asserted by the container.