Commit 8846b313 authored by Amy Unruh's avatar Amy Unruh

phase 2 of cassandra example overhaul

parent d800dca7
apiVersion: v1 apiVersion: v1
kind: ReplicationController kind: ReplicationController
metadata: metadata:
labels:
app: cassandra
name: cassandra name: cassandra
# The labels will be applied automatically
# from the labels in the pod template, if not set
# labels:
# app: cassandra
spec: spec:
replicas: 2 replicas: 2
selector: # The selector will be applied automatically
app: cassandra # from the labels in the pod template, if not set.
# selector:
# app: cassandra
template: template:
metadata: metadata:
labels: labels:
......
apiVersion: v1
kind: Pod
metadata:
labels:
app: cassandra
name: cassandra
spec:
containers:
- args:
- /run.sh
resources:
limits:
cpu: "0.1"
image: gcr.io/google-samples/cassandra:v8
name: cassandra
ports:
- name: cql
containerPort: 9042
- name: thrift
containerPort: 9160
volumeMounts:
- name: data
mountPath: /cassandra_data
env:
- name: MAX_HEAP_SIZE
value: 512M
- name: HEAP_NEWSIZE
value: 100M
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumes:
- name: data
emptyDir: {}
...@@ -262,7 +262,6 @@ func TestExampleObjectSchemas(t *testing.T) { ...@@ -262,7 +262,6 @@ func TestExampleObjectSchemas(t *testing.T) {
"cassandra-daemonset": &extensions.DaemonSet{}, "cassandra-daemonset": &extensions.DaemonSet{},
"cassandra-controller": &api.ReplicationController{}, "cassandra-controller": &api.ReplicationController{},
"cassandra-service": &api.Service{}, "cassandra-service": &api.Service{},
"cassandra": &api.Pod{},
}, },
"../examples/celery-rabbitmq": { "../examples/celery-rabbitmq": {
"celery-controller": &api.ReplicationController{}, "celery-controller": &api.ReplicationController{},
......
...@@ -1674,9 +1674,9 @@ __EOF__ ...@@ -1674,9 +1674,9 @@ __EOF__
##################### #####################
kube::log::status "Testing resource aliasing" kube::log::status "Testing resource aliasing"
kubectl create -f examples/cassandra/cassandra.yaml "${kube_flags[@]}" kubectl create -f examples/cassandra/cassandra-controller.yaml "${kube_flags[@]}"
kubectl create -f examples/cassandra/cassandra-service.yaml "${kube_flags[@]}" kubectl create -f examples/cassandra/cassandra-service.yaml "${kube_flags[@]}"
kube::test::get_object_assert "all -l'app=cassandra'" "{{range.items}}{{range .metadata.labels}}{{.}}:{{end}}{{end}}" 'cassandra:cassandra:' kube::test::get_object_assert "all -l'app=cassandra'" "{{range.items}}{{range .metadata.labels}}{{.}}:{{end}}{{end}}" 'cassandra:cassandra:cassandra:cassandra:'
kubectl delete all -l app=cassandra "${kube_flags[@]}" kubectl delete all -l app=cassandra "${kube_flags[@]}"
......
...@@ -477,7 +477,7 @@ func TestAnnotateObjectFromFile(t *testing.T) { ...@@ -477,7 +477,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
switch req.Method { switch req.Method {
case "GET": case "GET":
switch req.URL.Path { switch req.URL.Path {
case "/namespaces/test/pods/cassandra": case "/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil
default: default:
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req) t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
...@@ -485,7 +485,7 @@ func TestAnnotateObjectFromFile(t *testing.T) { ...@@ -485,7 +485,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
} }
case "PATCH": case "PATCH":
switch req.URL.Path { switch req.URL.Path {
case "/namespaces/test/pods/cassandra": case "/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil
default: default:
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req) t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
...@@ -504,7 +504,7 @@ func TestAnnotateObjectFromFile(t *testing.T) { ...@@ -504,7 +504,7 @@ func TestAnnotateObjectFromFile(t *testing.T) {
cmd := NewCmdAnnotate(f, buf) cmd := NewCmdAnnotate(f, buf)
cmd.SetOutput(buf) cmd.SetOutput(buf)
options := &AnnotateOptions{} options := &AnnotateOptions{}
options.filenames = []string{"../../../examples/cassandra/cassandra.yaml"} options.filenames = []string{"../../../examples/cassandra/cassandra-controller.yaml"}
args := []string{"a=b", "c-"} args := []string{"a=b", "c-"}
if err := options.Complete(f, buf, cmd, args); err != nil { if err := options.Complete(f, buf, cmd, args); err != nil {
t.Fatalf("unexpected error: %v", err) t.Fatalf("unexpected error: %v", err)
......
...@@ -337,7 +337,7 @@ func TestGetObjectsIdentifiedByFile(t *testing.T) { ...@@ -337,7 +337,7 @@ func TestGetObjectsIdentifiedByFile(t *testing.T) {
cmd := NewCmdGet(f, buf) cmd := NewCmdGet(f, buf)
cmd.SetOutput(buf) cmd.SetOutput(buf)
cmd.Flags().Set("filename", "../../../examples/cassandra/cassandra.yaml") cmd.Flags().Set("filename", "../../../examples/cassandra/cassandra-controller.yaml")
cmd.Run(cmd, []string{}) cmd.Run(cmd, []string{})
expected := []runtime.Object{&pods.Items[0]} expected := []runtime.Object{&pods.Items[0]}
...@@ -789,9 +789,9 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) { ...@@ -789,9 +789,9 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
Codec: codec, Codec: codec,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
switch req.URL.Path { switch req.URL.Path {
case "/namespaces/test/pods/cassandra": case "/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: objBody(codec, &pods[0])}, nil return &http.Response{StatusCode: 200, Body: objBody(codec, &pods[0])}, nil
case "/watch/namespaces/test/pods/cassandra": case "/watch/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: watchBody(codec, events)}, nil return &http.Response{StatusCode: 200, Body: watchBody(codec, events)}, nil
default: default:
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req) t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
...@@ -805,7 +805,7 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) { ...@@ -805,7 +805,7 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
cmd.SetOutput(buf) cmd.SetOutput(buf)
cmd.Flags().Set("watch", "true") cmd.Flags().Set("watch", "true")
cmd.Flags().Set("filename", "../../../examples/cassandra/cassandra.yaml") cmd.Flags().Set("filename", "../../../examples/cassandra/cassandra-controller.yaml")
cmd.Run(cmd, []string{}) cmd.Run(cmd, []string{})
expected := []runtime.Object{&pods[0], events[0].Object, events[1].Object} expected := []runtime.Object{&pods[0], events[0].Object, events[1].Object}
......
...@@ -333,7 +333,7 @@ func TestLabelForResourceFromFile(t *testing.T) { ...@@ -333,7 +333,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
switch req.Method { switch req.Method {
case "GET": case "GET":
switch req.URL.Path { switch req.URL.Path {
case "/namespaces/test/pods/cassandra": case "/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil
default: default:
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req) t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
...@@ -341,7 +341,7 @@ func TestLabelForResourceFromFile(t *testing.T) { ...@@ -341,7 +341,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
} }
case "PATCH": case "PATCH":
switch req.URL.Path { switch req.URL.Path {
case "/namespaces/test/pods/cassandra": case "/namespaces/test/replicationcontrollers/cassandra":
return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil return &http.Response{StatusCode: 200, Body: objBody(codec, &pods.Items[0])}, nil
default: default:
t.Fatalf("unexpected request: %#v\n%#v", req.URL, req) t.Fatalf("unexpected request: %#v\n%#v", req.URL, req)
...@@ -359,7 +359,7 @@ func TestLabelForResourceFromFile(t *testing.T) { ...@@ -359,7 +359,7 @@ func TestLabelForResourceFromFile(t *testing.T) {
buf := bytes.NewBuffer([]byte{}) buf := bytes.NewBuffer([]byte{})
cmd := NewCmdLabel(f, buf) cmd := NewCmdLabel(f, buf)
options := &LabelOptions{ options := &LabelOptions{
Filenames: []string{"../../../examples/cassandra/cassandra.yaml"}, Filenames: []string{"../../../examples/cassandra/cassandra-controller.yaml"},
} }
err := RunLabel(f, buf, cmd, []string{"a=b"}, options) err := RunLabel(f, buf, cmd, []string{"a=b"}, options)
......
...@@ -208,24 +208,14 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() { ...@@ -208,24 +208,14 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
return filepath.Join(framework.TestContext.RepoRoot, "examples", "cassandra", file) return filepath.Join(framework.TestContext.RepoRoot, "examples", "cassandra", file)
} }
serviceYaml := mkpath("cassandra-service.yaml") serviceYaml := mkpath("cassandra-service.yaml")
podYaml := mkpath("cassandra.yaml")
controllerYaml := mkpath("cassandra-controller.yaml") controllerYaml := mkpath("cassandra-controller.yaml")
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
By("Starting the cassandra service and pod") By("Starting the cassandra service")
framework.RunKubectlOrDie("create", "-f", serviceYaml, nsFlag) framework.RunKubectlOrDie("create", "-f", serviceYaml, nsFlag)
framework.RunKubectlOrDie("create", "-f", podYaml, nsFlag)
framework.Logf("waiting for first cassandra pod")
err := framework.WaitForPodRunningInNamespace(c, "cassandra", ns)
Expect(err).NotTo(HaveOccurred())
framework.Logf("waiting for thrift listener online")
_, err = framework.LookForStringInLog(ns, "cassandra", "cassandra", "Listening for thrift clients", serverStartTimeout)
Expect(err).NotTo(HaveOccurred())
framework.Logf("wait for service") framework.Logf("wait for service")
err = framework.WaitForEndpoint(c, ns, "cassandra") err := framework.WaitForEndpoint(c, ns, "cassandra")
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
// Create an RC with n nodes in it. Each node will then be verified. // Create an RC with n nodes in it. Each node will then be verified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment