Skip to content

Commit 65a5db6

Browse files
committed
Add end to end test for unset connection header
1 parent c489591 commit 65a5db6

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

internal/mode/static/nginx/config/servers_test.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,18 @@ func TestCreateServers(t *testing.T) {
656656
},
657657
}
658658

659+
keepAliveGroup := dataplane.BackendGroup{
660+
Source: hrNsName,
661+
RuleIdx: 4,
662+
Backends: []dataplane.Backend{
663+
{
664+
UpstreamName: "test_keep_alive_80",
665+
Valid: true,
666+
Weight: 1,
667+
},
668+
},
669+
}
670+
659671
filterGroup1 := dataplane.BackendGroup{Source: hrNsName, RuleIdx: 3}
660672

661673
filterGroup2 := dataplane.BackendGroup{Source: hrNsName, RuleIdx: 4}
@@ -976,6 +988,16 @@ func TestCreateServers(t *testing.T) {
976988
},
977989
},
978990
},
991+
{
992+
Path: "/keep-alive-enabled",
993+
PathType: dataplane.PathTypeExact,
994+
MatchRules: []dataplane.MatchRule{
995+
{
996+
Match: dataplane.Match{},
997+
BackendGroup: keepAliveGroup,
998+
},
999+
},
1000+
},
9791001
}
9801002

9811003
conf := dataplane.Configuration{
@@ -1432,6 +1454,13 @@ func TestCreateServers(t *testing.T) {
14321454
Type: http.InternalLocationType,
14331455
Includes: internalIncludes,
14341456
},
1457+
{
1458+
Path: "= /keep-alive-enabled",
1459+
ProxyPass: "http://test_keep_alive_80$request_uri",
1460+
ProxySetHeaders: createBaseProxySetHeaders(httpUpgradeHeader, unsetHTTPConnectionHeader),
1461+
Type: http.ExternalLocationType,
1462+
Includes: externalIncludes,
1463+
},
14351464
}
14361465
}
14371466

@@ -1483,7 +1512,16 @@ func TestCreateServers(t *testing.T) {
14831512
Content: []byte("include-1"),
14841513
},
14851514
})
1486-
result, httpMatchPair := createServers(conf, fakeGenerator, alwaysFalseKeepAliveChecker)
1515+
1516+
keepAliveEnabledUpstream := http.Upstream{
1517+
Name: "test_keep_alive_80",
1518+
KeepAlive: http.UpstreamKeepAlive{
1519+
Connections: 1,
1520+
},
1521+
}
1522+
keepAliveCheck := newKeepAliveChecker([]http.Upstream{keepAliveEnabledUpstream})
1523+
1524+
result, httpMatchPair := createServers(conf, fakeGenerator, keepAliveCheck)
14871525

14881526
g.Expect(httpMatchPair).To(Equal(allExpMatchPair))
14891527
g.Expect(helpers.Diff(expectedServers, result)).To(BeEmpty())

0 commit comments

Comments
 (0)