-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix service nodeport issue (naively), add an integration test to guar…
…d it. Add vendor to .gitignore to allow experimenting with upstream patches locally
- Loading branch information
Showing
4 changed files
with
90 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
vendor |
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,68 @@ | ||
package objectmatch | ||
|
||
import ( | ||
"testing" | ||
|
||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
"k8s.io/klog/klogr" | ||
) | ||
|
||
func TestIntegration_Service(t *testing.T) { | ||
|
||
if !*integration { | ||
t.Skip() | ||
} | ||
|
||
tests := []struct{ | ||
service *v1.Service | ||
}{ | ||
{ | ||
service: &v1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test-service", | ||
Namespace: testContext.Namespace, | ||
}, | ||
Spec: v1.ServiceSpec{ | ||
Ports: []v1.ServicePort{ | ||
{ | ||
Name: "http", | ||
Protocol: v1.ProtocolTCP, | ||
Port: 80, | ||
TargetPort: intstr.FromInt(80), | ||
}, | ||
}, | ||
Selector: map[string]string{ | ||
"app": "test", | ||
}, | ||
Type: v1.ServiceTypeLoadBalancer, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|
||
existingService, err := testContext.Client.CoreV1().Services(test.service.Namespace).Create(test.service) | ||
defer func() { | ||
testContext.Client.CoreV1().Pods(test.service.Namespace).Delete(test.service.Name, &metav1.DeleteOptions{ | ||
GracePeriodSeconds: new(int64), | ||
}) | ||
}() | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to create pod: %s", err.Error()) | ||
} | ||
|
||
|
||
matched, err := NewServiceMatcher(New(klogr.New())).Match(existingService, test.service) | ||
if err != nil { | ||
t.Fatalf("Failed to match objects: %s", err) | ||
} | ||
|
||
if !matched { | ||
t.Fatalf("Objects did not match") | ||
} | ||
} | ||
} |