Skip to content

Commit 385da29

Browse files
committed
add tests
1 parent 39d685f commit 385da29

File tree

2 files changed

+192
-0
lines changed

2 files changed

+192
-0
lines changed

test/cmd/newapp.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ os::cmd::expect_success_and_text 'oc new-app ruby-helloworld-sample --param MYSQ
9595
os::cmd::expect_success_and_text 'oc new-app -e FOO=BAR -f examples/jenkins/jenkins-ephemeral-template.json -o jsonpath="{.items[?(@.kind==\"DeploymentConfig\")].spec.template.spec.containers[0].env[?(@.name==\"FOO\")].value}" ' '^BAR$'
9696
os::cmd::expect_success_and_text 'oc new-app -e OPENSHIFT_ENABLE_OAUTH=false -f examples/jenkins/jenkins-ephemeral-template.json -o jsonpath="{.items[?(@.kind==\"DeploymentConfig\")].spec.template.spec.containers[0].env[?(@.name==\"OPENSHIFT_ENABLE_OAUTH\")].value}" ' 'false'
9797

98+
# check that multiple resource groups are printed with their respective external version
99+
os::cmd::expect_success_and_text 'oc new-app -f test/testdata/template_multiple_resource-gvs.yaml -o yaml' 'apiVersion: apps/v1beta1'
100+
# check that if an --output-version is requested on a list of varying resource kinds, an error is returned if
101+
# at least one of the resource groups does not support the given version
102+
os::cmd::expect_failure_and_text 'oc new-app -f test/testdata/template_multiple_resource-gvs.yaml -o yaml --output-version=v1' 'extensions.Deployment is not suitable for converting'
103+
os::cmd::expect_failure_and_text 'oc new-app -f test/testdata/template_multiple_resource-gvs.yaml -o yaml --output-version=extensions/v1beta1' 'api.Secret is not suitable for converting'
104+
os::cmd::expect_failure_and_not_text 'oc new-app -f test/testdata/template_multiple_resource-gvs.yaml -o yaml --output-version=apps/v1beta1' 'extensions.Deployment is not suitable for converting'
105+
98106
# check that an error is produced when using --context-dir with a template
99107
os::cmd::expect_failure_and_text 'oc new-app -f examples/sample-app/application-template-stibuild.json --context-dir=example' '\-\-context-dir is not supported when using a template'
100108

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
apiVersion: template.openshift.io/v1
2+
kind: Template
3+
metadata:
4+
name: prometheus-test
5+
annotations:
6+
"openshift.io/display-name": Prometheus
7+
description: |
8+
Creates two resources that are part of different groups with no overlapping groupversions.
9+
Used to test `new-app` versioned output when dealing with lists of varying objects.
10+
iconClass: icon-cogs
11+
tags: "monitoring,prometheus, alertmanager,time-series"
12+
parameters:
13+
- description: The namespace to instantiate prometheus under. Defaults to 'kube-system'.
14+
name: NAMESPACE
15+
value: kube-system
16+
- description: The location of the proxy image
17+
name: IMAGE_PROXY
18+
value: openshift/oauth-proxy:v1.0.0
19+
- description: The location of the prometheus image
20+
name: IMAGE_PROMETHEUS
21+
value: openshift/prometheus:v2.0.0-dev
22+
- description: The location of the alertmanager image
23+
name: IMAGE_ALERTMANAGER
24+
# TODO: Change to official openshift build
25+
value: openshift/prometheus-alertmanager:dev
26+
- description: The location of alert-buffer image
27+
name: IMAGE_ALERT_BUFFER
28+
# TODO: change to official openshift build
29+
value: ilackarms/message-buffer
30+
- description: The session secret for the proxy
31+
name: SESSION_SECRET
32+
generate: expression
33+
from: "[a-zA-Z0-9]{43}"
34+
objects:
35+
- apiVersion: v1
36+
kind: Secret
37+
metadata:
38+
name: prometheus-proxy
39+
namespace: "${NAMESPACE}"
40+
stringData:
41+
session_secret: "${SESSION_SECRET}="
42+
- apiVersion: extensions/v1beta1
43+
kind: Deployment
44+
metadata:
45+
labels:
46+
app: prometheus
47+
name: prometheus
48+
namespace: "${NAMESPACE}"
49+
spec:
50+
replicas: 1
51+
selector:
52+
matchLabels:
53+
app: prometheus
54+
template:
55+
metadata:
56+
labels:
57+
app: prometheus
58+
name: prometheus
59+
spec:
60+
serviceAccountName: prometheus
61+
containers:
62+
# Deploy Prometheus behind an oauth proxy
63+
- name: prom-proxy
64+
image: ${IMAGE_PROXY}
65+
imagePullPolicy: IfNotPresent
66+
ports:
67+
- containerPort: 8443
68+
name: web
69+
args:
70+
- -provider=openshift
71+
- -https-address=:8443
72+
- -email-domain=*
73+
- -upstream=http://localhost:9090
74+
- -client-id=system:serviceaccount:${NAMESPACE}:prometheus
75+
- '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}'
76+
- '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}}'
77+
- -tls-cert=/etc/tls/private/tls.crt
78+
- -tls-key=/etc/tls/private/tls.key
79+
- -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
80+
- -cookie-secret-file=/etc/proxy/secrets/session_secret
81+
- -skip-auth-regex=^/metrics
82+
volumeMounts:
83+
- mountPath: /etc/tls/private
84+
name: prometheus-tls
85+
- mountPath: /etc/proxy/secrets
86+
name: prometheus-secrets
87+
- mountPath: /prometheus
88+
name: prometheus-data
89+
90+
- name: prometheus
91+
args:
92+
- --storage.tsdb.retention=6h
93+
- --config.file=/etc/prometheus/prometheus.yml
94+
- --web.listen-address=localhost:9090
95+
image: ${IMAGE_PROMETHEUS}
96+
imagePullPolicy: IfNotPresent
97+
volumeMounts:
98+
- mountPath: /etc/prometheus
99+
name: prometheus-config
100+
- mountPath: /prometheus
101+
name: prometheus-data
102+
103+
# Deploy alertmanager behind prometheus-alert-buffer behind an oauth proxy
104+
# use http port=4190 and https port=9943 to differ from prom-proxy
105+
- name: alerts-proxy
106+
image: ${IMAGE_PROXY}
107+
imagePullPolicy: IfNotPresent
108+
ports:
109+
- containerPort: 9443
110+
name: web
111+
args:
112+
- -provider=openshift
113+
- -https-address=:9443
114+
- -http-address=:4190
115+
- -email-domain=*
116+
- -upstream=http://localhost:9099
117+
- -client-id=system:serviceaccount:${NAMESPACE}:prometheus
118+
- '-openshift-sar={"resource": "namespaces", "verb": "get", "name": "${NAMESPACE}"}'
119+
- '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "name": "${NAMESPACE}"}}'
120+
- -tls-cert=/etc/tls/private/tls.crt
121+
- -tls-key=/etc/tls/private/tls.key
122+
- -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
123+
- -cookie-secret-file=/etc/proxy/secrets/session_secret
124+
volumeMounts:
125+
- mountPath: /etc/tls/private
126+
name: alerts-tls
127+
- mountPath: /etc/proxy/secrets
128+
name: alerts-secrets
129+
130+
- name: alert-buffer
131+
args:
132+
- --storage-path=/alert-buffer/messages.db
133+
image: ${IMAGE_ALERT_BUFFER}
134+
imagePullPolicy: IfNotPresent
135+
volumeMounts:
136+
- mountPath: /alert-buffer
137+
name: alert-buffer-data
138+
ports:
139+
- containerPort: 9099
140+
name: alert-buf
141+
142+
- name: alertmanager
143+
args:
144+
- -config.file=/etc/alertmanager/alertmanager.yml
145+
image: ${IMAGE_ALERTMANAGER}
146+
imagePullPolicy: IfNotPresent
147+
ports:
148+
- containerPort: 9093
149+
name: web
150+
volumeMounts:
151+
- mountPath: /etc/alertmanager
152+
name: alertmanager-config
153+
- mountPath: /alertmanager
154+
name: alertmanager-data
155+
156+
restartPolicy: Always
157+
volumes:
158+
- name: prometheus-config
159+
configMap:
160+
defaultMode: 420
161+
name: prometheus
162+
- name: prometheus-secrets
163+
secret:
164+
secretName: prometheus-proxy
165+
- name: prometheus-tls
166+
secret:
167+
secretName: prometheus-tls
168+
- name: prometheus-data
169+
emptyDir: {}
170+
- name: alertmanager-config
171+
configMap:
172+
defaultMode: 420
173+
name: prometheus-alerts
174+
- name: alerts-secrets
175+
secret:
176+
secretName: alerts-proxy
177+
- name: alerts-tls
178+
secret:
179+
secretName: prometheus-alerts-tls
180+
- name: alertmanager-data
181+
emptyDir: {}
182+
- name: alert-buffer-data #TODO: make persistent
183+
emptyDir: {}
184+

0 commit comments

Comments
 (0)