-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
237 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
source ../common.sh | ||
|
||
$KUBECTL_NAME create -f ../../manifests/appcontroller.yaml | ||
wait-appcontroller | ||
|
||
$KUBECTL_NAME create -f deps.yaml | ||
|
||
cat timedout-pod.yaml | $KUBECTL_NAME create -f - | ||
cat pod.yaml | $KUBECTL_NAME exec -i k8s-appcontroller kubeac wrap | $KUBECTL_NAME create -f - | ||
cat pod2.yaml | $KUBECTL_NAME exec -i k8s-appcontroller kubeac wrap | $KUBECTL_NAME create -f - | ||
|
||
$KUBECTL_NAME exec k8s-appcontroller ac-run | ||
$KUBECTL_NAME logs -f k8s-appcontroller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
source ../common.sh | ||
|
||
$KUBECTL_NAME delete -f deps.yaml | ||
|
||
cat timedout-pod.yaml | $KUBECTL_NAME delete -f - | ||
cat pod.yaml | $KUBECTL_NAME exec -i k8s-appcontroller kubeac wrap | $KUBECTL_NAME delete -f - | ||
cat pod2.yaml | $KUBECTL_NAME exec -i k8s-appcontroller kubeac wrap | $KUBECTL_NAME delete -f - | ||
|
||
$KUBECTL_NAME delete -f ../../manifests/appcontroller.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: appcontroller.k8s/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: ce1b11dc-2850-1dad-a7dd-302038af20af | ||
parent: pod/timed-out-pod | ||
child: pod/eventually-alive-pod | ||
--- | ||
apiVersion: appcontroller.k8s/v1alpha1 | ||
kind: Dependency | ||
metadata: | ||
name: 6d3a53be-6cec-425d-aec0-e188d739e9f6 | ||
parent: pod/eventually-alive-pod | ||
child: pod/eventually-alive-pod2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: eventually-alive-pod | ||
spec: | ||
containers: | ||
- command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- echo ok > /tmp/health | ||
image: gcr.io/google_containers/busybox | ||
name: test-container | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: eventually-alive-pod2 | ||
spec: | ||
containers: | ||
- command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- echo ok > /tmp/health | ||
image: gcr.io/google_containers/busybox | ||
name: test-container | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: appcontroller.k8s/v1alpha1 | ||
kind: Definition | ||
metadata: | ||
name: pod-timed-out-pod | ||
meta: | ||
timeout: 5 | ||
on-error: ignore-all | ||
pod: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: timed-out-pod | ||
spec: | ||
containers: | ||
- command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- sleep 30; echo ok > /tmp/health; sleep 60 | ||
image: gcr.io/google_containers/busybox | ||
readinessProbe: | ||
exec: | ||
command: | ||
- /bin/cat | ||
- /tmp/health | ||
name: test-container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2016 Mirantis | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package resources | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Mirantis/k8s-AppController/pkg/mocks" | ||
) | ||
|
||
// TestGetStringMeta checks metadata retrieval from a resource | ||
func TestGetStringMeta(t *testing.T) { | ||
r := mocks.NewResource("fake", "not ready") | ||
|
||
if GetStringMeta(r, "non-existing key", "default") != "default" { | ||
t.Error("GetStringMeta for non-existing key returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": "value"}) | ||
|
||
if GetStringMeta(r, "non-existing key", "default") != "default" { | ||
t.Error("GetStringMeta for non-existing key returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": 1}) | ||
|
||
if GetStringMeta(r, "key", "default") != "default" { | ||
t.Error("GetStringMeta for non-string value returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": "value"}) | ||
|
||
if GetStringMeta(r, "key", "default") != "value" { | ||
t.Error("GetStringMeta returned not an actual value") | ||
} | ||
} | ||
|
||
// TestGetIntMeta checks metadata retrieval from a resource | ||
func TestGetIntMeta(t *testing.T) { | ||
r := mocks.NewResource("fake", "not ready") | ||
|
||
if GetIntMeta(r, "non-existing key", -1) != -1 { | ||
t.Error("GetIntMeta for non-existing key returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": "value"}) | ||
|
||
if GetIntMeta(r, "non-existing key", -1) != -1 { | ||
t.Error("GetIntMeta for non-existing key returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": "value"}) | ||
|
||
if GetIntMeta(r, "key", -1) != -1 { | ||
t.Error("GetIntMeta for non-int value returned not a default value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": 42}) | ||
|
||
if GetIntMeta(r, "key", -1) != 42 { | ||
t.Error("GetIntMeta returned not an actual value") | ||
} | ||
|
||
r = mocks.NewResourceWithMeta("fake", "not ready", map[string]interface{}{"key": 42.}) | ||
|
||
if GetIntMeta(r, "key", -1) != 42 { | ||
t.Error("GetIntMeta returned not an actual value") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters