Skip to content

Commit b8a28a6

Browse files
committed
Add review feedback
1 parent a2ace83 commit b8a28a6

File tree

2 files changed

+23
-30
lines changed

2 files changed

+23
-30
lines changed

internal/mode/static/nginx/config/policies/upstreamsettings/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
// Processor processes UpstreamSettingsPolicies. It implements policies.UpstreamSettingsProcessor.
99
type Processor struct{}
1010

11-
// NewProcessor returns a new instance of Processor.
11+
// NewProcessor returns a new Processor.
1212
func NewProcessor() Processor {
1313
return Processor{}
1414
}

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

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import (
1818
)
1919

2020
var (
21-
httpBaseHeaders = createBaseProxySetHeaders(httpUpgradeHeader, httpConnectionHeader)
22-
grpcBaseHeaders = createBaseProxySetHeaders(grpcAuthorityHeader)
21+
httpBaseHeaders = createBaseProxySetHeaders(httpUpgradeHeader, httpConnectionHeader)
22+
grpcBaseHeaders = createBaseProxySetHeaders(grpcAuthorityHeader)
23+
alwaysFalseKeepAliveChecker = func(_ string) bool { return false }
2324
)
2425

2526
func TestExecuteServers(t *testing.T) {
@@ -187,7 +188,7 @@ func TestExecuteServers(t *testing.T) {
187188
)
188189

189190
gen := GeneratorImpl{}
190-
results := gen.executeServers(conf, fakeGenerator, newKeepAliveChecker([]http.Upstream{}))
191+
results := gen.executeServers(conf, fakeGenerator, alwaysFalseKeepAliveChecker)
191192
g.Expect(results).To(HaveLen(len(expectedResults)))
192193

193194
for _, res := range results {
@@ -326,11 +327,8 @@ func TestExecuteServers_IPFamily(t *testing.T) {
326327
g := NewWithT(t)
327328

328329
gen := GeneratorImpl{}
329-
results := gen.executeServers(
330-
test.config,
331-
&policiesfakes.FakeGenerator{},
332-
newKeepAliveChecker([]http.Upstream{}),
333-
)
330+
results := gen.executeServers(test.config, &policiesfakes.FakeGenerator{}, alwaysFalseKeepAliveChecker)
331+
334332
g.Expect(results).To(HaveLen(2))
335333
serverConf := string(results[0].data)
336334
httpMatchConf := string(results[1].data)
@@ -448,11 +446,7 @@ func TestExecuteServers_RewriteClientIP(t *testing.T) {
448446
g := NewWithT(t)
449447

450448
gen := GeneratorImpl{}
451-
results := gen.executeServers(
452-
test.config,
453-
&policiesfakes.FakeGenerator{},
454-
newKeepAliveChecker([]http.Upstream{}),
455-
)
449+
results := gen.executeServers(test.config, &policiesfakes.FakeGenerator{}, alwaysFalseKeepAliveChecker)
456450
g.Expect(results).To(HaveLen(2))
457451
serverConf := string(results[0].data)
458452
httpMatchConf := string(results[1].data)
@@ -494,7 +488,7 @@ func TestExecuteServers_Plus(t *testing.T) {
494488
g := NewWithT(t)
495489

496490
gen := GeneratorImpl{plus: true}
497-
results := gen.executeServers(config, &policiesfakes.FakeGenerator{}, newKeepAliveChecker([]http.Upstream{}))
491+
results := gen.executeServers(config, &policiesfakes.FakeGenerator{}, alwaysFalseKeepAliveChecker)
498492
g.Expect(results).To(HaveLen(2))
499493

500494
serverConf := string(results[0].data)
@@ -578,11 +572,7 @@ func TestExecuteForDefaultServers(t *testing.T) {
578572
g := NewWithT(t)
579573

580574
gen := GeneratorImpl{}
581-
serverResults := gen.executeServers(
582-
tc.conf,
583-
&policiesfakes.FakeGenerator{},
584-
newKeepAliveChecker([]http.Upstream{}),
585-
)
575+
serverResults := gen.executeServers(tc.conf, &policiesfakes.FakeGenerator{}, alwaysFalseKeepAliveChecker)
586576
g.Expect(serverResults).To(HaveLen(2))
587577
serverConf := string(serverResults[0].data)
588578
httpMatchConf := string(serverResults[1].data)
@@ -1493,7 +1483,7 @@ func TestCreateServers(t *testing.T) {
14931483
Content: []byte("include-1"),
14941484
},
14951485
})
1496-
result, httpMatchPair := createServers(conf, fakeGenerator, newKeepAliveChecker([]http.Upstream{}))
1486+
result, httpMatchPair := createServers(conf, fakeGenerator, alwaysFalseKeepAliveChecker)
14971487

14981488
g.Expect(httpMatchPair).To(Equal(allExpMatchPair))
14991489
g.Expect(helpers.Diff(expectedServers, result)).To(BeEmpty())
@@ -1714,7 +1704,7 @@ func TestCreateServersConflicts(t *testing.T) {
17141704
result, _ := createServers(
17151705
dataplane.Configuration{HTTPServers: httpServers},
17161706
&policiesfakes.FakeGenerator{},
1717-
newKeepAliveChecker([]http.Upstream{}),
1707+
alwaysFalseKeepAliveChecker,
17181708
)
17191709
g.Expect(helpers.Diff(expectedServers, result)).To(BeEmpty())
17201710
})
@@ -1865,7 +1855,7 @@ func TestCreateServers_Includes(t *testing.T) {
18651855

18661856
conf := dataplane.Configuration{HTTPServers: httpServers, SSLServers: sslServers}
18671857

1868-
actualServers, matchPairs := createServers(conf, fakeGenerator, newKeepAliveChecker([]http.Upstream{}))
1858+
actualServers, matchPairs := createServers(conf, fakeGenerator, alwaysFalseKeepAliveChecker)
18691859
g.Expect(matchPairs).To(BeEmpty())
18701860
g.Expect(actualServers).To(HaveLen(len(expServers)))
18711861

@@ -2026,12 +2016,7 @@ func TestCreateLocations_Includes(t *testing.T) {
20262016
},
20272017
})
20282018

2029-
locations, matches, grpc := createLocations(
2030-
&httpServer,
2031-
"1",
2032-
fakeGenerator,
2033-
newKeepAliveChecker([]http.Upstream{}),
2034-
)
2019+
locations, matches, grpc := createLocations(&httpServer, "1", fakeGenerator, alwaysFalseKeepAliveChecker)
20352020

20362021
g := NewWithT(t)
20372022
g.Expect(grpc).To(BeFalse())
@@ -2221,7 +2206,7 @@ func TestCreateLocationsRootPath(t *testing.T) {
22212206
},
22222207
"1",
22232208
&policiesfakes.FakeGenerator{},
2224-
newKeepAliveChecker([]http.Upstream{}),
2209+
alwaysFalseKeepAliveChecker,
22252210
)
22262211
g.Expect(locs).To(Equal(test.expLocations))
22272212
g.Expect(httpMatchPair).To(BeEmpty())
@@ -3055,6 +3040,14 @@ func TestCreateBaseProxySetHeaders(t *testing.T) {
30553040
},
30563041
expBaseHeaders: append(expBaseHeaders, httpConnectionHeader, httpUpgradeHeader),
30573042
},
3043+
{
3044+
msg: "unset connection header and upgrade header",
3045+
additionalHeaders: []http.Header{
3046+
unsetHTTPConnectionHeader,
3047+
httpUpgradeHeader,
3048+
},
3049+
expBaseHeaders: append(expBaseHeaders, unsetHTTPConnectionHeader, httpUpgradeHeader),
3050+
},
30583051
}
30593052

30603053
for _, test := range tests {

0 commit comments

Comments
 (0)