Skip to content

Commit

Permalink
add test for key-only env
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Dec 16, 2016
1 parent 247b247 commit 5db7399
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 1 deletion.
7 changes: 6 additions & 1 deletion script/test/cmd/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ convert::expect_success "kompose --bundle $KOMPOSE_ROOT/script/test/fixtures/bun
# Test related to kompose --bundle convert to ensure that DSB bundles are converted properly
convert::expect_success_and_warning "kompose --bundle $KOMPOSE_ROOT/script/test/fixtures/bundles/dsb/docker-voting-bundle.dsb convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/bundles/dsb/output-k8s.json" "Service cannot be created because of missing port."


######
# Test related to restart options in docker-compose
# kubernetes test
Expand All @@ -113,4 +112,10 @@ convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-o
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-no.yml --provider openshift convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-no.json"
convert::expect_success "kompose -f $KOMPOSE_ROOT/script/test/fixtures/restart-options/docker-compose-restart-onfail.yml --provider openshift convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/restart-options/output-os-restart-onfail.json"

######
# Test key-only envrionment variable
export $(cat $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/envs)
convert::expect_success "kompose --file $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/env.yml convert --stdout" "$KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/output-k8s.json"
unset $(cat $KOMPOSE_ROOT/script/test/fixtures/keyonly-envs/envs | cut -d'=' -f1)

exit $EXIT_STATUS
25 changes: 25 additions & 0 deletions script/test/fixtures/keyonly-envs/env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "2"

services:
redis-master:
image: gcr.io/google_containers/redis:e2e
ports:
- "6379"
redis-slave:
image: gcr.io/google_samples/gb-redisslave:v1
ports:
- "6379"
environment:
- GET_HOSTS_FROM=dns
- RACK_ENV=development
- SHOW=true
- SESSION_SECRET
frontend:
image: gcr.io/google-samples/gb-frontend:v4
ports:
- "80:80"
environment:
GET_HOSTS_FROM: dns
RACK_ENV: development
SHOW: 'true'
SESSION_SECRET:
1 change: 1 addition & 0 deletions script/test/fixtures/keyonly-envs/envs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SESSION_SECRET=session
235 changes: 235 additions & 0 deletions script/test/fixtures/keyonly-envs/output-k8s.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
{
"kind": "List",
"apiVersion": "v1",
"metadata": {},
"items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "frontend",
"creationTimestamp": null,
"labels": {
"service": "frontend"
}
},
"spec": {
"ports": [
{
"name": "80",
"protocol": "TCP",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "frontend"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis-master",
"creationTimestamp": null,
"labels": {
"service": "redis-master"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis-master"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis-slave",
"creationTimestamp": null,
"labels": {
"service": "redis-slave"
}
},
"spec": {
"ports": [
{
"name": "6379",
"protocol": "TCP",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis-slave"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "frontend",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "frontend"
}
},
"spec": {
"containers": [
{
"name": "frontend",
"image": "gcr.io/google-samples/gb-frontend:v4",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"env": [
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "RACK_ENV",
"value": "development"
},
{
"name": "SESSION_SECRET",
"value": "session"
},
{
"name": "SHOW",
"value": "true"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis-master",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis-master"
}
},
"spec": {
"containers": [
{
"name": "redis-master",
"image": "gcr.io/google_containers/redis:e2e",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis-slave",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis-slave"
}
},
"spec": {
"containers": [
{
"name": "redis-slave",
"image": "gcr.io/google_samples/gb-redisslave:v1",
"ports": [
{
"containerPort": 6379,
"protocol": "TCP"
}
],
"env": [
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "RACK_ENV",
"value": "development"
},
{
"name": "SHOW",
"value": "true"
},
{
"name": "SESSION_SECRET",
"value": "session"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
}
]
}

0 comments on commit 5db7399

Please sign in to comment.