Skip to content

Commit

Permalink
feat(split-timeout): Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lowaiz authored and Aluxima committed Jul 4, 2024
1 parent 54be719 commit 1708910
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions pkg/envoy/ingress_translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ func TestEqualityVirtualHosts(t *testing.T) {
func TestEquals(t *testing.T) {
ingress := newGenericIngress("foo.app.com", "foo.cluster.com")
ingress2 := newGenericIngress("bar.app.com", "foo.bar.com")
c := translateIngresses([]*k8s.Ingress{ingress, ingress2}, false, []*v1.Secret{})
c2 := translateIngresses([]*k8s.Ingress{ingress, ingress2}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{ingress, ingress2}, false, []*v1.Secret{}, timeouts)
c2 := translateIngresses([]*k8s.Ingress{ingress, ingress2}, false, []*v1.Secret{}, timeouts)

vmatch, cmatch := c.equals(c2)
if vmatch != true {
Expand All @@ -221,8 +226,13 @@ func TestNotEquals(t *testing.T) {
ingress2 := newGenericIngress("foo.app.com", "bar.cluster.com")
ingress3 := newGenericIngress("foo.baz.com", "bar.cluster.com")
ingress4 := newGenericIngress("foo.howdy.com", "bar.cluster.com")
c := translateIngresses([]*k8s.Ingress{ingress, ingress3, ingress2}, false, []*v1.Secret{})
c2 := translateIngresses([]*k8s.Ingress{ingress, ingress2, ingress4}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{ingress, ingress3, ingress2}, false, []*v1.Secret{}, timeouts)
c2 := translateIngresses([]*k8s.Ingress{ingress, ingress2, ingress4}, false, []*v1.Secret{}, timeouts)

vmatch, cmatch := c.equals(c2)
if vmatch == true {
Expand All @@ -237,8 +247,13 @@ func TestNotEquals(t *testing.T) {
func TestPartialEquals(t *testing.T) {
ingress := newGenericIngress("foo.app.com", "bar.cluster.com")
ingress2 := newGenericIngress("foo.app.com", "foo.cluster.com")
c := translateIngresses([]*k8s.Ingress{ingress2}, false, []*v1.Secret{})
c2 := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{ingress2}, false, []*v1.Secret{}, timeouts)
c2 := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{}, timeouts)

vmatch, cmatch := c2.equals(c)
if vmatch != true {
Expand All @@ -252,7 +267,12 @@ func TestPartialEquals(t *testing.T) {

func TestGeneratesForSingleIngress(t *testing.T) {
ingress := newGenericIngress("foo.app.com", "foo.cluster.com")
c := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{}, timeouts)

if len(c.VirtualHosts) != 1 {
t.Error("expected 1 virtual host")
Expand Down Expand Up @@ -284,7 +304,12 @@ func TestGeneratesForSingleIngress(t *testing.T) {
func TestGeneratesForMultipleIngressSharingSpecHost(t *testing.T) {
fooIngress := newGenericIngress("app.com", "foo.com")
barIngress := newGenericIngress("app.com", "bar.com")
c := translateIngresses([]*k8s.Ingress{fooIngress, barIngress}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{fooIngress, barIngress}, false, []*v1.Secret{}, timeouts)

if len(c.VirtualHosts) != 1 {
t.Error("expected 1 virtual host")
Expand Down Expand Up @@ -339,7 +364,12 @@ func TestFilterNonMatchingIngresses(t *testing.T) {

func TestIngressWithIP(t *testing.T) {
ingress := newIngressIP("app.com", "127.0.0.1")
c := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{})
timeouts := DefaultTimeouts{
Cluster: 30 * time.Second,
Route: 15 * time.Second,
PerTry: 5 * time.Second,
}
c := translateIngresses([]*k8s.Ingress{ingress}, false, []*v1.Secret{}, timeouts)
if c.Clusters[0].Hosts[0] != "127.0.0.1" {
t.Errorf("expected cluster host to be IP address, was %s", c.Clusters[0].Hosts[0])
}
Expand Down

0 comments on commit 1708910

Please sign in to comment.