fix expose multi protocols issue

This commit is contained in:
AdoHe
2016-05-12 00:07:07 -04:00
parent def7639457
commit ad97cddb3e
11 changed files with 293 additions and 8 deletions

View File

@@ -404,6 +404,78 @@ func TestGenerateService(t *testing.T) {
},
},
},
{
generator: ServiceGeneratorV2{},
params: map[string]interface{}{
"selector": "foo=bar",
"name": "test",
"ports": "80,8080",
"protocols": "8080/UDP",
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
},
Ports: []api.ServicePort{
{
Name: "port-1",
Port: 80,
Protocol: api.ProtocolTCP,
TargetPort: intstr.FromInt(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: api.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
},
},
},
},
},
{
generator: ServiceGeneratorV2{},
params: map[string]interface{}{
"selector": "foo=bar",
"name": "test",
"ports": "80,8080,8081",
"protocols": "8080/UDP,8081/TCP",
},
expected: api.Service{
ObjectMeta: api.ObjectMeta{
Name: "test",
},
Spec: api.ServiceSpec{
Selector: map[string]string{
"foo": "bar",
},
Ports: []api.ServicePort{
{
Name: "port-1",
Port: 80,
Protocol: api.ProtocolTCP,
TargetPort: intstr.FromInt(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: api.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
},
{
Name: "port-3",
Port: 8081,
Protocol: api.ProtocolTCP,
TargetPort: intstr.FromInt(8081),
},
},
},
},
},
}
for _, test := range tests {
obj, err := test.generator.Generate(test.params)