-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding verification to operators around params (#1033)
- Loading branch information
Showing
14 changed files
with
468 additions
and
10 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
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,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestOperatorVerify(t *testing.T) { | ||
file := "invalid-params" | ||
out := &bytes.Buffer{} | ||
cmd := newOperatorVerifyCmd(fs, out) | ||
// if err := cmd.RunE(cmd, []string{"testdata/invalid-zk"}); err != nil { | ||
if err := cmd.RunE(cmd, []string{"./testdata/invalidzk"}); err != nil { | ||
assert.Error(t, err) | ||
} | ||
|
||
gp := filepath.Join("testdata", file+".golden") | ||
|
||
if *updateGolden { | ||
t.Log("update golden file") | ||
if err := ioutil.WriteFile(gp, out.Bytes(), 0644); err != nil { | ||
t.Fatalf("failed to update golden file: %s", err) | ||
} | ||
} | ||
g, err := ioutil.ReadFile(gp) | ||
if err != nil { | ||
t.Fatalf("failed reading .golden: %s", err) | ||
} | ||
|
||
assert.Equal(t, out.String(), string(g), "yaml does not match .golden file %s", gp) | ||
} |
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,3 @@ | ||
Errors | ||
parameter "Cpus" has a duplicate | ||
parameter "comma," has a the invalid char ',' |
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,51 @@ | ||
apiVersion: kudo.dev/v1beta1 | ||
name: "zookeeper" | ||
version: "0.1.0" | ||
appVersion: "3.4.10" | ||
kudoVersion: 0.2.0 | ||
kubernetesVersion: 1.15.0 | ||
maintainers: | ||
- name: Alena Varkockova | ||
email: avarkockova@mesosphere.com | ||
- name: Tom Runyon | ||
email: runyontr@gmail.com | ||
- name: Ken Sipe | ||
email: kensipe@gmail.com | ||
url: https://zookeeper.apache.org/ | ||
tasks: | ||
- name: infra | ||
kind: Apply | ||
spec: | ||
resources: | ||
- services.yaml | ||
- pdb.yaml | ||
- name: app | ||
kind: Apply | ||
spec: | ||
resources: | ||
- statefulset.yaml | ||
- name: validation | ||
kind: Apply | ||
spec: | ||
resources: | ||
- validation.yaml | ||
plans: | ||
deploy: | ||
strategy: serial | ||
phases: | ||
- name: zookeeper | ||
strategy: parallel | ||
steps: | ||
- name: everything | ||
tasks: | ||
- infra | ||
- app | ||
validation: | ||
strategy: serial | ||
phases: | ||
- name: connection | ||
strategy: parallel | ||
steps: | ||
- name: connection | ||
tasks: | ||
- validation |
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,14 @@ | ||
apiVersion: kudo.dev/v1beta1 | ||
parameters: | ||
- name: memory | ||
description: Amount of memory to provide to Zookeeper pods | ||
default: "1Gi" | ||
- name: cpus | ||
description: Amount of cpu to provide to Zookeeper pods | ||
default: "0.25" | ||
- name: Cpus | ||
description: Amount of cpu to provide to Zookeeper pods | ||
default: "0.25" | ||
- name: comma, | ||
description: Amount of cpu to provide to Zookeeper pods | ||
default: "0.25" |
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,14 @@ | ||
apiVersion: policy/v1beta1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ .Name }}-pdb | ||
namespace: {{ .Namespace }} | ||
labels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
maxUnavailable: 1 |
34 changes: 34 additions & 0 deletions
34
pkg/kudoctl/cmd/testdata/invalidzk/templates/services.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,34 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: hs | ||
namespace: {{ .Namespace }} | ||
labels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
spec: | ||
ports: | ||
- port: 2888 | ||
name: server | ||
- port: 3888 | ||
name: leader-election | ||
clusterIP: None | ||
selector: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cs | ||
namespace: {{ .Namespace }} | ||
labels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
spec: | ||
ports: | ||
- port: 2181 | ||
name: client | ||
selector: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} |
87 changes: 87 additions & 0 deletions
87
pkg/kudoctl/cmd/testdata/invalidzk/templates/statefulset.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,87 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ .Name }} | ||
namespace: {{ .Namespace }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
serviceName: {{ .Name }}-hs | ||
replicas: 3 | ||
updateStrategy: | ||
type: RollingUpdate | ||
podManagementPolicy: Parallel | ||
template: | ||
metadata: | ||
labels: | ||
app: zookeeper | ||
zookeeper: {{ .Name }} | ||
spec: | ||
containers: | ||
- name: kubernetes-zookeeper | ||
imagePullPolicy: Always | ||
image: "k8s.gcr.io/kubernetes-zookeeper:1.0-3.4.10" | ||
resources: | ||
requests: | ||
memory: "{{ .Params.memory }}" | ||
cpu: "{{ .Params.cpus }}" | ||
ports: | ||
- containerPort: 2181 | ||
name: client | ||
- containerPort: 2888 | ||
name: server | ||
- containerPort: 3888 | ||
name: leader-election | ||
command: | ||
- sh | ||
- -c | ||
- "start-zookeeper \ | ||
--servers=3 \ | ||
--data_dir=/var/lib/zookeeper/data \ | ||
--data_log_dir=/var/lib/zookeeper/data/log \ | ||
--conf_dir=/opt/zookeeper/conf \ | ||
--client_port=2181 \ | ||
--election_port=3888 \ | ||
--server_port=2888 \ | ||
--tick_time=2000 \ | ||
--init_limit=10 \ | ||
--sync_limit=5 \ | ||
--heap=512M \ | ||
--max_client_cnxns=60 \ | ||
--snap_retain_count=3 \ | ||
--purge_interval=12 \ | ||
--max_session_timeout=40000 \ | ||
--min_session_timeout=4000 \ | ||
--log_level=INFO" | ||
readinessProbe: | ||
exec: | ||
command: | ||
- sh | ||
- -c | ||
- "zookeeper-ready 2181" | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 5 | ||
livenessProbe: | ||
exec: | ||
command: | ||
- sh | ||
- -c | ||
- "zookeeper-ready 2181" | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 5 | ||
volumeMounts: | ||
- name: datadir | ||
mountPath: /var/lib/zookeeper | ||
securityContext: | ||
runAsUser: 1000 | ||
fsGroup: 1000 | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: datadir | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 2Gi |
27 changes: 27 additions & 0 deletions
27
pkg/kudoctl/cmd/testdata/invalidzk/templates/validation.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,27 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: zookeeper-validation | ||
spec: | ||
template: | ||
metadata: | ||
name: "validation" | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: kubernetes-zookeeper | ||
imagePullPolicy: Always | ||
image: "k8s.gcr.io/kubernetes-zookeeper:1.0-3.4.10" | ||
env: | ||
- name: CONN | ||
value: zk-zk-0.zk-hs:2181,zk-zk-1.zk-hs:2181,zk-zk-2.zk-hs:2181 | ||
resources: | ||
requests: | ||
memory: "{{ .Params.memory }}" | ||
cpu: "{{ .Params.cpus }}" | ||
command: | ||
- sh | ||
- -c | ||
- "/opt/zookeeper/bin/zkCLI.sh \ | ||
--server $CONN \ | ||
ls /" |
Oops, something went wrong.