-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin unit testing jsonnet microservices (#2229)
* Attempt unit testing jsonnet microservices Signed-off-by: Zach Leslie <[email protected]> * Config update * Update structure for microservices test * Wire up CI to run the jsonnet tests * Separate compile step, use output in first test --------- Signed-off-by: Zach Leslie <[email protected]>
- Loading branch information
Showing
10 changed files
with
299 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.PHONY: test | ||
test: jsonnet-compile jsonnet-test tanka-test | ||
|
||
tanka-test: | ||
tk show test/environments/default | ||
|
||
jsonnet-compile: | ||
@cd test/ && \ | ||
mkdir -p outputs && \ | ||
jb install && \ | ||
jsonnet -J vendor -J lib -o outputs/base.json environments/default/main.jsonnet | ||
|
||
jsonnet-test: jsonnet-compile | ||
@cd test/ && \ | ||
jsonnet -J vendor -J lib test1.jsonnet | ||
|
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
133 changes: 133 additions & 0 deletions
133
operations/jsonnet/microservices/test/environments/default/main.jsonnet
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,133 @@ | ||
local tempo = import '../../../tempo.libsonnet'; | ||
|
||
tempo { | ||
_images+:: { | ||
// images can be overridden here if desired | ||
}, | ||
|
||
_config+:: { | ||
cluster: 'k3d', | ||
namespace: 'default', | ||
compactor+: { | ||
}, | ||
querier+: { | ||
}, | ||
ingester+: { | ||
pvc_size: '5Gi', | ||
pvc_storage_class: 'local-path', | ||
}, | ||
distributor+: { | ||
receivers: { | ||
opencensus: null, | ||
jaeger: { | ||
protocols: { | ||
thrift_http: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
metrics_generator+: { | ||
ephemeral_storage_limit_size: '2Gi', | ||
ephemeral_storage_request_size: '1Gi', | ||
}, | ||
memcached+: { | ||
replicas: 1, | ||
}, | ||
vulture+: { | ||
replicas: 0, | ||
// Disable search until release | ||
tempoSearchBackoffDuration: '0s', | ||
}, | ||
backend: 's3', | ||
bucket: 'tempo', | ||
tempo_query_url: 'http://query-frontend:3200', | ||
|
||
overrides_configmap_name: 'tempo-overrides', | ||
overrides+:: {}, | ||
}, | ||
|
||
// manually overriding to get tempo to talk to minio | ||
tempo_config+:: { | ||
storage+: { | ||
trace+: { | ||
s3+: { | ||
endpoint: 'minio:9000', | ||
access_key: 'tempo', | ||
secret_key: 'supersecret', | ||
insecure: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
local k = import 'ksonnet-util/kausal.libsonnet', | ||
local service = k.core.v1.service, | ||
tempo_service: | ||
k.util.serviceFor($.tempo_distributor_deployment) | ||
+ service.mixin.metadata.withName('tempo'), | ||
|
||
local container = k.core.v1.container, | ||
local containerPort = k.core.v1.containerPort, | ||
tempo_compactor_container+:: | ||
k.util.resourcesRequests('500m', '500Mi'), | ||
|
||
tempo_distributor_container+:: | ||
k.util.resourcesRequests('500m', '500Mi') + | ||
container.withPortsMixin([ | ||
containerPort.new('opencensus', 55678), | ||
containerPort.new('jaeger-http', 14268), | ||
]), | ||
|
||
tempo_ingester_container+:: | ||
k.util.resourcesRequests('500m', '500Mi'), | ||
|
||
// clear affinity so we can run multiple ingesters on a single node | ||
tempo_ingester_statefulset+: { | ||
spec+: { | ||
template+: { | ||
spec+: { | ||
affinity: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
tempo_querier_container+:: | ||
k.util.resourcesRequests('500m', '500Mi'), | ||
|
||
tempo_query_frontend_container+:: | ||
k.util.resourcesRequests('300m', '500Mi'), | ||
|
||
// clear affinity so we can run multiple instances of memcached on a single node | ||
memcached_all+: { | ||
statefulSet+: { | ||
spec+: { | ||
template+: { | ||
spec+: { | ||
affinity: {}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
local ingress = k.networking.v1.ingress, | ||
local rule = k.networking.v1.ingressRule, | ||
local path = k.networking.v1.httpIngressPath, | ||
ingress: | ||
ingress.new('ingress') + | ||
ingress.mixin.metadata | ||
.withAnnotationsMixin({ | ||
'ingress.kubernetes.io/ssl-redirect': 'false', | ||
}) + | ||
ingress.mixin.spec.withRules( | ||
rule.http.withPaths([ | ||
path.withPath('/') | ||
+ path.withPathType('ImplementationSpecific') | ||
+ path.backend.service.withName('grafana') | ||
+ path.backend.service.port.withNumber(3000), | ||
]), | ||
), | ||
|
||
|
||
} |
12 changes: 12 additions & 0 deletions
12
operations/jsonnet/microservices/test/environments/default/spec.json
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,12 @@ | ||
{ | ||
"apiVersion": "tanka.dev/v1alpha1", | ||
"kind": "Environment", | ||
"metadata": { | ||
"name": "environments/default" | ||
}, | ||
"spec": { | ||
"namespace": "default", | ||
"resourceDefaults": {}, | ||
"expectVersions": {} | ||
} | ||
} |
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 @@ | ||
{ | ||
"version": 1, | ||
"dependencies": [ | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/jsonnet-libs.git", | ||
"subdir": "ksonnet-util" | ||
} | ||
}, | ||
"version": "master" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/jsonnet-libs.git", | ||
"subdir": "memcached" | ||
} | ||
}, | ||
"version": "master" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/docsonnet.git", | ||
"subdir": "doc-util" | ||
} | ||
}, | ||
"version": "master" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git", | ||
"subdir": "1.26" | ||
} | ||
}, | ||
"version": "main" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/testonnet.git", | ||
"subdir": "" | ||
} | ||
}, | ||
"version": "master" | ||
} | ||
], | ||
"legacyImports": true | ||
} |
66 changes: 66 additions & 0 deletions
66
operations/jsonnet/microservices/test/jsonnetfile.lock.json
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,66 @@ | ||
{ | ||
"version": 1, | ||
"dependencies": [ | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/jsonnet-libs.git", | ||
"subdir": "ksonnet-util" | ||
} | ||
}, | ||
"version": "3b08e7d37511dfd39af6027d07788a5ca8ec71b1", | ||
"sum": "0y3AFX9LQSpfWTxWKSwoLgbt0Wc9nnCwhMH2szKzHv0=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/grafana/jsonnet-libs.git", | ||
"subdir": "memcached" | ||
} | ||
}, | ||
"version": "3b08e7d37511dfd39af6027d07788a5ca8ec71b1", | ||
"sum": "SWywAq4U0MRPMbASU0Ez8O9ArRNeoZzb75sEuReueow=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/docsonnet.git", | ||
"subdir": "doc-util" | ||
} | ||
}, | ||
"version": "ff76f6d8edde6366c6dcf81a356481b0e344566b", | ||
"sum": "OxjkWDF0oHmwV52hhyoFW3bwtwgke8s/EOPNRiICPTI=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git", | ||
"subdir": "1.26" | ||
} | ||
}, | ||
"version": "a0779420abf73f90167d449a9e527319ced7d134", | ||
"sum": "q6ZaBe1Ciob0O3QbLqtEfOnCGt5rsv5A9RCFN3+Ex/I=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/testonnet.git", | ||
"subdir": "" | ||
} | ||
}, | ||
"version": "9b30f882132b8d8754535fbcee822b804c90405f", | ||
"sum": "MB1dww51rdYJTWAAFkrOXMeMNxzZ5yyFPjPxaERDb1k=" | ||
}, | ||
{ | ||
"source": { | ||
"git": { | ||
"remote": "https://github.com/jsonnet-libs/xtd.git", | ||
"subdir": "" | ||
} | ||
}, | ||
"version": "3e494e02563b9eababbb24f0dfca0a50e03dc0b3", | ||
"sum": "GP6SaIzrnD0HRw/EeI3iO9HboA2dnBizgEpxw3m7Ph4=" | ||
} | ||
], | ||
"legacyImports": false | ||
} |
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 @@ | ||
import 'github.com/jsonnet-libs/k8s-libsonnet/1.26/main.libsonnet' |
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,12 @@ | ||
local default = import 'environments/default/main.jsonnet'; | ||
local base = import 'outputs/base.json'; | ||
local test = import 'testonnet/main.libsonnet'; | ||
|
||
test.new(std.thisFile) | ||
+ test.case.new( | ||
'Basic', | ||
test.expect.eq( | ||
default, | ||
base | ||
) | ||
) |