mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-19 01:47:02 +00:00
Add failing acceptance test for disk caching feature
This commit is contained in:
parent
bcf1fc9568
commit
a03c1cb90e
3 changed files with 51 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
|||
FROM bats/bats:v1.2.1
|
||||
RUN apk --no-cache add ca-certificates parallel
|
||||
RUN apk --no-cache add ca-certificates parallel python
|
||||
COPY bin/kubeconform /code/bin/
|
||||
COPY acceptance.bats /code/acceptance.bats
|
||||
COPY fixtures /code/fixtures
|
||||
|
|
|
|||
|
|
@ -1,5 +1,36 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
cp /etc/hosts /etc/hosts.original
|
||||
cp /etc/resolv.conf /etc/resolv.conf.original
|
||||
|
||||
teardown() {
|
||||
cat /etc/resolv.conf.original > /etc/resolv.conf
|
||||
cat /etc/hosts.original > /etc/hosts
|
||||
}
|
||||
|
||||
blockNetwork() {
|
||||
echo "nameserver 127.0.0.1" > /etc/resolv.conf
|
||||
}
|
||||
|
||||
startRegistryHTTPServer() {
|
||||
/bin/sh -c '
|
||||
# Start simple static server for schemas
|
||||
cd fixtures/registry/
|
||||
python -m SimpleHTTPServer 3000 2>/dev/null 1>/dev/null &
|
||||
echo -n $! > /tmp/registry-pid
|
||||
|
||||
# Wait until server is ready
|
||||
until wget http://localhost:3000/trainingjob-sagemaker-v1.json -qO /dev/null 2>/dev/null
|
||||
do
|
||||
echo -n ""
|
||||
done
|
||||
' 3>/dev/null
|
||||
}
|
||||
|
||||
stopRegistryHTTPServer() {
|
||||
kill "$(cat /tmp/registry-pid)"
|
||||
}
|
||||
|
||||
@test "Pass when parsing a valid Kubernetes config YAML file" {
|
||||
run bin/kubeconform -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
@ -204,13 +235,29 @@
|
|||
}
|
||||
|
||||
@test "Pass when parsing a valid Kubernetes config YAML file and store cache" {
|
||||
run mkdir cache
|
||||
run rm -rf cache && mkdir cache
|
||||
run bin/kubeconform -cache cache -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0" ]
|
||||
[ "`ls cache/ | wc -l`" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "Pass when parsing a valid Kubernetes config YAML file offline using cache" {
|
||||
startRegistryHTTPServer
|
||||
|
||||
run rm -rf cache && mkdir cache
|
||||
run bin/kubeconform -cache cache -schema-location 'http://localhost:3000/{{ .ResourceKind }}{{ .KindSuffix }}.json' -summary fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0" ]
|
||||
|
||||
stopRegistryHTTPServer
|
||||
blockNetwork
|
||||
|
||||
run bin/kubeconform -cache cache -schema-location 'http://localhost:3000/{{ .ResourceKind }}{{ .KindSuffix }}.json' -summary fixtures/test_crd.yaml
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0" ]
|
||||
}
|
||||
|
||||
@test "Fail when cache folder does not exist" {
|
||||
run bin/kubeconform -cache cache_does_not_exist -summary fixtures/valid.yaml
|
||||
[ "$status" -eq 1 ]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
"type": "string"
|
||||
},
|
||||
"metadata": {
|
||||
"type": "object"
|
||||
"$ref": "https://kubernetesjsonschema.dev/v1.14.0/_definitions.json#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
|
||||
"description": "Standard object metadata."
|
||||
},
|
||||
"spec": {
|
||||
"description": "TrainingJobSpec defines the desired state of TrainingJob",
|
||||
|
|
|
|||
Loading…
Reference in a new issue