Fix expansion test

pull/500/head
jackgr 9 years ago
parent 7cc0a496cf
commit 0b3f545bf4

@ -756,44 +756,16 @@ func TestReplicatedService(t *testing.T) {
&expansion.ServiceResponse{ &expansion.ServiceResponse{
Resources: []interface{}{ Resources: []interface{}{
map[string]interface{}{ map[string]interface{}{
"type": "Service",
"name": "test_invocation-service",
"properties": map[string]interface{}{
"kind": "Service",
"apiVersion": "v1",
"namespace": "default",
"metadata": map[string]interface{}{
"name": "test_invocation-service",
"labels": map[string]interface{}{
"name": "test_invocation-service",
},
},
"spec": map[string]interface{}{
"ports": []interface{}{
map[string]interface{}{
"name": "test_invocation",
"port": 1234.0,
"targetPort": 1234.0,
},
},
"selector": map[string]interface{}{
"name": "test_invocation",
},
},
},
},
map[string]interface{}{
"type": "ReplicationController",
"name": "test_invocation-rc", "name": "test_invocation-rc",
"properties": map[string]interface{}{ "properties": map[string]interface{}{
"kind": "ReplicationController",
"apiVersion": "v1", "apiVersion": "v1",
"namespace": "default", "kind": "ReplicationController",
"metadata": map[string]interface{}{ "metadata": map[string]interface{}{
"name": "test_invocation-rc",
"labels": map[string]interface{}{ "labels": map[string]interface{}{
"name": "test_invocation-rc", "name": "test_invocation-rc",
}, },
"name": "test_invocation-rc",
"namespace": "default",
}, },
"spec": map[string]interface{}{ "spec": map[string]interface{}{
"replicas": 3.0, "replicas": 3.0,
@ -824,6 +796,34 @@ func TestReplicatedService(t *testing.T) {
}, },
}, },
}, },
"type": "ReplicationController",
},
map[string]interface{}{
"name": "test_invocation-service",
"properties": map[string]interface{}{
"apiVersion": "v1",
"kind": "Service",
"metadata": map[string]interface{}{
"labels": map[string]interface{}{
"name": "test_invocation-service",
},
"name": "test_invocation-service",
"namespace": "default",
},
"spec": map[string]interface{}{
"ports": []interface{}{
map[string]interface{}{
"name": "test_invocation",
"port": 1234.0,
"targetPort": 1234.0,
},
},
"selector": map[string]interface{}{
"name": "test_invocation",
},
},
},
"type": "Service",
}, },
}, },
}, },

@ -37,20 +37,20 @@ def GenerateConfig(context):
service = { service = {
'name': service_name, 'name': service_name,
'type': service_type,
'properties': { 'properties': {
'apiVersion': 'v1', 'apiVersion': 'v1',
'kind': 'Service', 'kind': 'Service',
'metadata': { 'metadata': {
'labels': GenerateLabels(context, service_name),
'name': service_name, 'name': service_name,
'namespace': namespace, 'namespace': namespace,
'labels': GenerateLabels(context, service_name),
}, },
'spec': { 'spec': {
'ports': [GenerateServicePorts(context, container_name)], 'ports': [GenerateServicePorts(context, container_name)],
'selector': GenerateLabels(context, name) 'selector': GenerateLabels(context, name)
} }
} },
'type': service_type,
} }
set_up_external_lb = context.properties.get('external_service', None) set_up_external_lb = context.properties.get('external_service', None)
if set_up_external_lb: if set_up_external_lb:
@ -58,7 +58,6 @@ def GenerateConfig(context):
cluster_ip = context.properties.get('cluster_ip', None) cluster_ip = context.properties.get('cluster_ip', None)
if cluster_ip: if cluster_ip:
service['properties']['spec']['clusterIP'] = cluster_ip service['properties']['spec']['clusterIP'] = cluster_ip
config['resources'].append(service)
rc = { rc = {
'name': rc_name, 'name': rc_name,
@ -66,10 +65,10 @@ def GenerateConfig(context):
'properties': { 'properties': {
'apiVersion': 'v1', 'apiVersion': 'v1',
'kind': 'ReplicationController', 'kind': 'ReplicationController',
'namespace': namespace,
'metadata': { 'metadata': {
'name': rc_name,
'labels': GenerateLabels(context, rc_name), 'labels': GenerateLabels(context, rc_name),
'name': rc_name,
'namespace': namespace,
}, },
'spec': { 'spec': {
'replicas': context.properties['replicas'], 'replicas': context.properties['replicas'],
@ -82,8 +81,8 @@ def GenerateConfig(context):
'containers': [ 'containers': [
{ {
'env': GenerateEnv(context), 'env': GenerateEnv(context),
'name': container_name,
'image': context.properties['image'], 'image': context.properties['image'],
'name': container_name,
'ports': [ 'ports': [
{ {
'name': container_name, 'name': container_name,
@ -121,6 +120,7 @@ def GenerateConfig(context):
} }
config['resources'].append(rc) config['resources'].append(rc)
config['resources'].append(service)
return yaml.dump(config) return yaml.dump(config)

Loading…
Cancel
Save