Skip to content

Commit

Permalink
Add tests for reporting errors in tcp listeners in aggregate filter c…
Browse files Browse the repository at this point in the history
…hains
  • Loading branch information
ashishb-solo committed Jun 30, 2023
1 parent bd83416 commit c6b5f72
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions projects/gloo/pkg/utils/validation/proxy_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ func GetProxyError(proxyRpt *validation.ProxyReport) error {
for _, httpListenerReport := range listenerType.AggregateListenerReport.GetHttpListenerReports() {
errs = append(errs, getHttpListenerReportErrs(httpListenerReport)...)
}
for _, tcpListenerReport := range listenerType.AggregateListenerReport.GetTcpListenerReports() {
errs = append(errs, getTcpListenerReportErrs(tcpListenerReport)...)
}
}
}

Expand Down
33 changes: 33 additions & 0 deletions projects/gloo/pkg/utils/validation/proxy_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/solo-io/gloo/projects/gloo/pkg/defaults"
"github.com/solo-io/gloo/projects/gloo/pkg/utils"
"golang.org/x/exp/maps"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -264,9 +265,41 @@ var _ = Describe("validation utils", func() {
},
)

// aggregate listener reports are a map of tcp listener reports -
// one entry in the map for each listener; here, we extract the
// map, then obtain the first and only key for the single listener
// that we created
tcpListenerReportsMap := rpt.ListenerReports[0].ListenerTypeReport.(*validation.ListenerReport_AggregateListenerReport).AggregateListenerReport.TcpListenerReports
tcpListenerReport := tcpListenerReportsMap[maps.Keys(tcpListenerReportsMap)[0]]

// populate the errors - we should hit all cases in
// getTcpListenerReportErrs with the errors we create here
tcpListenerReport.Errors = append(tcpListenerReport.Errors,
&validation.TcpListenerReport_Error{
Type: validation.TcpListenerReport_Error_SSLConfigError,
Reason: "test SSLConfig Error",
},
)
tcpListenerReport.TcpHostReports = append(tcpListenerReport.TcpHostReports,
&validation.TcpHostReport{
Errors: []*validation.TcpHostReport_Error{
{
Type: validation.TcpHostReport_Error_InvalidDestinationError,
Reason: "testing invalid destination error",
},
{
Type: validation.TcpHostReport_Error_ProcessingError,
Reason: "testing processing error",
},
},
})

err := GetProxyError(rpt)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Listener Error: BindPortNotUniqueError. Reason: bind port not unique"))
Expect(err.Error()).To(ContainSubstring("TcpListener Error: SSLConfigError. Reason: test SSLConfig Error"))
Expect(err.Error()).To(ContainSubstring("TcpHost Error: InvalidDestinationError. Reason: testing invalid destination error"))
Expect(err.Error()).To(ContainSubstring("TcpHost Error: ProcessingError. Reason: testing processing error"))
})
It("aggregates the errors at every level for hybrid listener", func() {
proxy := makeHybridProxy()
Expand Down

0 comments on commit c6b5f72

Please sign in to comment.