Skip to content

Commit 384d224

Browse files
committed
Reformat test code
1 parent 4070e37 commit 384d224

11 files changed

Lines changed: 209 additions & 210 deletions

File tree

src/main/kotlin/eu/openanalytics/shinyproxyoperator/ingress/skipper/IngressFactory.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,25 @@ class IngressFactory(private val kubeClient: KubernetesClient) {
5858
"kubernetes.io/ingress.class" to "skipper",
5959
"zalando.org/skipper-predicate" to "True()",
6060
"zalando.org/skipper-filter" to
61-
"""setRequestHeader("X-ShinyProxy-Instance", "$hashOfSpec")""" +
62-
""" -> """ +
63-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${shinyProxy.hashOfCurrentSpec}")""" +
64-
""" -> """ +
65-
"""appendResponseHeader("Set-Cookie", "sp-instance=$hashOfSpec; $security Path=$cookiePath")""" +
66-
""" -> """ +
67-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${shinyProxy.hashOfCurrentSpec}; $security Path=$cookiePath")"""
61+
"""setRequestHeader("X-ShinyProxy-Instance", "$hashOfSpec")""" +
62+
""" -> """ +
63+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${shinyProxy.hashOfCurrentSpec}")""" +
64+
""" -> """ +
65+
"""appendResponseHeader("Set-Cookie", "sp-instance=$hashOfSpec; $security Path=$cookiePath")""" +
66+
""" -> """ +
67+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${shinyProxy.hashOfCurrentSpec}; $security Path=$cookiePath")"""
6868

6969
)
7070
} else {
7171
mapOf(
7272
"kubernetes.io/ingress.class" to "skipper",
7373
"zalando.org/skipper-predicate" to """True() && Cookie("sp-instance", "$hashOfSpec")""",
7474
"zalando.org/skipper-filter" to
75-
"""setRequestHeader("X-ShinyProxy-Instance", "$hashOfSpec")""" +
76-
""" -> """ +
77-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${shinyProxy.hashOfCurrentSpec}")""" +
78-
""" -> """ +
79-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${shinyProxy.hashOfCurrentSpec}; $security Path=$cookiePath")"""
75+
"""setRequestHeader("X-ShinyProxy-Instance", "$hashOfSpec")""" +
76+
""" -> """ +
77+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${shinyProxy.hashOfCurrentSpec}")""" +
78+
""" -> """ +
79+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${shinyProxy.hashOfCurrentSpec}; $security Path=$cookiePath")"""
8080
)
8181
}
8282

@@ -131,4 +131,4 @@ class IngressFactory(private val kubeClient: KubernetesClient) {
131131
return builder.build()
132132
}
133133

134-
}
134+
}

src/test/kotlin/eu/openanalytics/shinyproxyoperator/MainIntegrationTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,13 @@ class MainIntegrationTest : IntegrationTestBase() {
688688
"kubernetes.io/ingress.class" to "skipper",
689689
"zalando.org/skipper-predicate" to "True()",
690690
"zalando.org/skipper-filter" to
691-
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
692-
""" -> """ +
693-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
694-
""" -> """ +
695-
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Secure; Path=/sub-path/")""" +
696-
""" -> """ +
697-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/sub-path/")"""
691+
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
692+
""" -> """ +
693+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
694+
""" -> """ +
695+
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Secure; Path=/sub-path/")""" +
696+
""" -> """ +
697+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/sub-path/")"""
698698
), ingress.metadata.annotations)
699699

700700
assertEquals(1, ingress.spec.rules.size)
@@ -761,13 +761,13 @@ class MainIntegrationTest : IntegrationTestBase() {
761761
"kubernetes.io/ingress.class" to "skipper",
762762
"zalando.org/skipper-predicate" to "True()",
763763
"zalando.org/skipper-filter" to
764-
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
765-
""" -> """ +
766-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
767-
""" -> """ +
768-
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Path=/")""" +
769-
""" -> """ +
770-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Path=/")"""
764+
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
765+
""" -> """ +
766+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
767+
""" -> """ +
768+
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Path=/")""" +
769+
""" -> """ +
770+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Path=/")"""
771771
), ingress.metadata.annotations)
772772

773773
job.cancel()

src/test/kotlin/eu/openanalytics/shinyproxyoperator/helpers/ShinyProxyTestInstance.kt

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import io.fabric8.kubernetes.api.model.IntOrString
2929
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
3030
import io.fabric8.kubernetes.client.internal.readiness.Readiness
3131
import kotlinx.coroutines.withTimeout
32-
import java.lang.IllegalStateException
3332
import kotlin.test.assertEquals
3433
import kotlin.test.assertNotEquals
3534
import kotlin.test.assertNotNull
@@ -87,10 +86,10 @@ class ShinyProxyTestInstance(private val namespace: String,
8786
assertEquals("sp-${sp.metadata.name}-ing-${hash}".take(63), ingress.metadata.name)
8887

8988
assertEquals(mapOf(
90-
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
91-
LabelFactory.NAME_LABEL to sp.metadata.name,
92-
LabelFactory.INSTANCE_LABEL to hash,
93-
LabelFactory.INGRESS_IS_LATEST to isLatest.toString()
89+
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
90+
LabelFactory.NAME_LABEL to sp.metadata.name,
91+
LabelFactory.INSTANCE_LABEL to hash,
92+
LabelFactory.INGRESS_IS_LATEST to isLatest.toString()
9493
), ingress.metadata.labels)
9594

9695
assertEquals(1, ingress.metadata.ownerReferences.size)
@@ -104,24 +103,24 @@ class ShinyProxyTestInstance(private val namespace: String,
104103
"kubernetes.io/ingress.class" to "skipper",
105104
"zalando.org/skipper-predicate" to "True()",
106105
"zalando.org/skipper-filter" to
107-
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
108-
""" -> """ +
109-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
110-
""" -> """ +
111-
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")""" +
112-
""" -> """ +
113-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")"""
106+
"""setRequestHeader("X-ShinyProxy-Instance", "${sp.hashOfCurrentSpec}")""" +
107+
""" -> """ +
108+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
109+
""" -> """ +
110+
"""appendResponseHeader("Set-Cookie", "sp-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")""" +
111+
""" -> """ +
112+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")"""
114113
), ingress.metadata.annotations)
115114
} else {
116115
assertEquals(mapOf(
117116
"kubernetes.io/ingress.class" to "skipper",
118117
"zalando.org/skipper-predicate" to """True() && Cookie("sp-instance", "$hash")""",
119118
"zalando.org/skipper-filter" to
120-
"""setRequestHeader("X-ShinyProxy-Instance", "$hash")""" +
121-
""" -> """ +
122-
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
123-
""" -> """ +
124-
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")"""
119+
"""setRequestHeader("X-ShinyProxy-Instance", "$hash")""" +
120+
""" -> """ +
121+
"""setRequestHeader("X-ShinyProxy-Latest-Instance", "${sp.hashOfCurrentSpec}")""" +
122+
""" -> """ +
123+
"""appendResponseHeader("Set-Cookie", "sp-latest-instance=${sp.hashOfCurrentSpec}; Secure; Path=/")"""
125124

126125
), ingress.metadata.annotations)
127126
}
@@ -152,9 +151,9 @@ class ShinyProxyTestInstance(private val namespace: String,
152151
assertEquals(80, service.spec.ports[0].port)
153152
assertEquals(IntOrString(8080), service.spec.ports[0].targetPort)
154153
assertEquals(mapOf(
155-
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
156-
LabelFactory.NAME_LABEL to sp.metadata.name,
157-
LabelFactory.INSTANCE_LABEL to hash
154+
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
155+
LabelFactory.NAME_LABEL to sp.metadata.name,
156+
LabelFactory.INSTANCE_LABEL to hash
158157
), service.spec.selector)
159158

160159
}
@@ -232,9 +231,9 @@ class ShinyProxyTestInstance(private val namespace: String,
232231

233232
fun assertLabelsAreCorrect(resource: HasMetadata, sp: ShinyProxy) {
234233
assertEquals(mapOf(
235-
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
236-
LabelFactory.NAME_LABEL to sp.metadata.name,
237-
LabelFactory.INSTANCE_LABEL to hash
234+
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
235+
LabelFactory.NAME_LABEL to sp.metadata.name,
236+
LabelFactory.INSTANCE_LABEL to hash
238237
), resource.metadata.labels)
239238
}
240239

@@ -256,4 +255,4 @@ class ShinyProxyTestInstance(private val namespace: String,
256255
throw IllegalStateException("Instance not found")
257256
}
258257

259-
}
258+
}

src/test/resources/configs/serviceaccount.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ metadata:
44
name: shinyproxy-apps-role
55
namespace: itest
66
rules:
7-
- apiGroups: [""]
8-
resources: ["pods"]
9-
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
7+
- apiGroups: [ "" ]
8+
resources: [ "pods" ]
9+
verbs: [ "get", "list", "watch", "create", "update", "patch", "delete" ]
1010
---
1111
kind: RoleBinding
1212
apiVersion: rbac.authorization.k8s.io/v1

src/test/resources/configs/simple_config.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ kind: ShinyProxy
33
metadata:
44
name: example-shinyproxy
55
spec:
6-
fqdn: itest.local
7-
image: openanalytics/shinyproxy:2.5.0
8-
proxy:
9-
title: Open Analytics Shiny Proxy
10-
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11-
landingPage: /
12-
heartbeatRate: 10000
13-
heartbeatTimeout: 60000
14-
port: 8080
15-
authentication: simple
16-
containerBackend: kubernetes
17-
kubernetes:
18-
namespace: itest
19-
users:
6+
fqdn: itest.local
7+
image: openanalytics/shinyproxy:2.5.0
8+
proxy:
9+
title: Open Analytics Shiny Proxy
10+
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11+
landingPage: /
12+
heartbeatRate: 10000
13+
heartbeatTimeout: 60000
14+
port: 8080
15+
authentication: simple
16+
containerBackend: kubernetes
17+
kubernetes:
18+
namespace: itest
19+
users:
2020
- name: demo
2121
password: demo
2222
groups: scientists
2323
- name: demo2
2424
password: demo2
2525
groups: mathematicians
26-
specs:
26+
specs:
2727
- id: 01_hello
2828
displayName: Hello Application
2929
description: Application which demonstrates the basics of a Shiny app
30-
containerCmd: ["R", "-e", "shinyproxy::run_01_hello()"]
30+
containerCmd: [ "R", "-e", "shinyproxy::run_01_hello()" ]
3131
containerImage: openanalytics/shinyproxy-demo
3232
- id: 06_tabsets
33-
container-cmd: ["R", "-e", "shinyproxy::run_06_tabsets()"]
34-
container-image: openanalytics/shinyproxy-demo
33+
container-cmd: [ "R", "-e", "shinyproxy::run_06_tabsets()" ]
34+
container-image: openanalytics/shinyproxy-demo

src/test/resources/configs/simple_config_multiple_namespaces.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,38 @@ kind: ShinyProxy
33
metadata:
44
name: example-shinyproxy
55
spec:
6-
fqdn: itest.local
7-
image: openanalytics/shinyproxy:2.5.0
8-
proxy:
9-
title: Open Analytics Shiny Proxy
10-
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11-
landingPage: /
12-
heartbeatRate: 10000
13-
heartbeatTimeout: 60000
14-
port: 8080
15-
authentication: simple
16-
containerBackend: kubernetes
17-
kubernetes:
18-
namespace: itest
19-
users:
6+
fqdn: itest.local
7+
image: openanalytics/shinyproxy:2.5.0
8+
proxy:
9+
title: Open Analytics Shiny Proxy
10+
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11+
landingPage: /
12+
heartbeatRate: 10000
13+
heartbeatTimeout: 60000
14+
port: 8080
15+
authentication: simple
16+
containerBackend: kubernetes
17+
kubernetes:
18+
namespace: itest
19+
users:
2020
- name: demo
2121
password: demo
2222
groups: scientists
2323
- name: demo2
2424
password: demo2
2525
groups: mathematicians
26-
specs:
26+
specs:
2727
- id: 01_hello
2828
displayName: Hello Application
2929
description: Application which demonstrates the basics of a Shiny app
30-
containerCmd: ["R", "-e", "shinyproxy::run_01_hello()"]
30+
containerCmd: [ "R", "-e", "shinyproxy::run_01_hello()" ]
3131
containerImage: openanalytics/shinyproxy-demo
3232
kubernetes-pod-patches: |
3333
- op: replace
3434
path: /metadata/namespace
3535
value: my-namespace
3636
- id: 06_tabsets
37-
container-cmd: ["R", "-e", "shinyproxy::run_06_tabsets()"]
37+
container-cmd: [ "R", "-e", "shinyproxy::run_06_tabsets()" ]
3838
container-image: openanalytics/shinyproxy-demo
39-
appNamespaces:
40-
- my-namespace
39+
appNamespaces:
40+
- my-namespace

src/test/resources/configs/simple_config_subpath1.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ kind: ShinyProxy
33
metadata:
44
name: example-shinyproxy
55
spec:
6-
fqdn: itest.local
7-
image: openanalytics/shinyproxy:2.5.0
8-
proxy:
9-
title: Open Analytics Shiny Proxy
10-
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11-
landingPage: /
12-
heartbeatRate: 10000
13-
heartbeatTimeout: 60000
14-
port: 8080
15-
authentication: simple
16-
containerBackend: kubernetes
17-
kubernetes:
18-
namespace: itest
19-
users:
6+
fqdn: itest.local
7+
image: openanalytics/shinyproxy:2.5.0
8+
proxy:
9+
title: Open Analytics Shiny Proxy
10+
logoUrl: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
11+
landingPage: /
12+
heartbeatRate: 10000
13+
heartbeatTimeout: 60000
14+
port: 8080
15+
authentication: simple
16+
containerBackend: kubernetes
17+
kubernetes:
18+
namespace: itest
19+
users:
2020
- name: demo
2121
password: demo
2222
groups: scientists
2323
- name: demo2
2424
password: demo2
2525
groups: mathematicians
26-
specs:
26+
specs:
2727
- id: 01_hello
2828
displayName: Hello Application
2929
description: Application which demonstrates the basics of a Shiny app
30-
containerCmd: ["R", "-e", "shinyproxy::run_01_hello()"]
30+
containerCmd: [ "R", "-e", "shinyproxy::run_01_hello()" ]
3131
containerImage: openanalytics/shinyproxy-demo
3232
- id: 06_tabsets
33-
container-cmd: ["R", "-e", "shinyproxy::run_06_tabsets()"]
33+
container-cmd: [ "R", "-e", "shinyproxy::run_06_tabsets()" ]
3434
container-image: openanalytics/shinyproxy-demo
35-
server:
36-
servlet:
37-
context-path: /sub-path
35+
server:
36+
servlet:
37+
context-path: /sub-path

0 commit comments

Comments
 (0)