Skip to content

Commit 50ef7bb

Browse files
committed
test: check xds update more stable.
Signed-off-by: doujiang24 <doujiang24@gmail.com>
1 parent ab476ca commit 50ef7bb

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

api/plugins/tests/integration/controlplane/control_plane.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ func (cp *ControlPlane) useGoPluginConfig(t *testing.T, config *filtermanager.Fi
218218
}
219219
}
220220

221+
detectorRouteName := getRandomString(8)
221222
defaultRoutes := []*route.Route{
222223
{
223-
Name: getRandomString(8),
224+
Name: detectorRouteName,
224225
Match: &route.RouteMatch{
225226
PathSpecifier: &route.RouteMatch_Path{
226227
Path: "/detect_if_the_rds_takes_effect",
@@ -286,7 +287,7 @@ func (cp *ControlPlane) useGoPluginConfig(t *testing.T, config *filtermanager.Fi
286287

287288
if willTimeout {
288289
time.Sleep(1 * time.Second)
289-
require.False(t, dp.Configured())
290+
require.False(t, dp.Configured(detectorRouteName))
290291

291292
cp.updateConfig(t, Resources{
292293
resource.RouteType: []types.Resource{
@@ -306,7 +307,7 @@ func (cp *ControlPlane) useGoPluginConfig(t *testing.T, config *filtermanager.Fi
306307

307308
// Wait for DP to use the configuration.
308309
require.Eventually(t, func() bool {
309-
return dp.Configured()
310+
return dp.Configured(detectorRouteName)
310311
}, 10*time.Second, 50*time.Millisecond, "failed to wait for DP to use the configuration")
311312
}
312313

api/plugins/tests/integration/dataplane/data_plane.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ type DataPlane struct {
5858
opt *Option
5959
done chan error
6060

61-
latestRouteVersion string
62-
6361
dataPlanePort string
6462
adminAPIPort string
6563
soPath string
@@ -590,7 +588,7 @@ func (dp *DataPlane) Grpcurl(importPath, protoFile, fullMethodName, req string)
590588
return cmd.CombinedOutput()
591589
}
592590

593-
func (dp *DataPlane) Configured() bool {
591+
func (dp *DataPlane) Configured(expectedVersion string) bool {
594592
resp, err := dp.Head("/detect_if_the_rds_takes_effect", nil)
595593
if err != nil {
596594
return false
@@ -599,11 +597,7 @@ func (dp *DataPlane) Configured() bool {
599597
return false
600598
}
601599
name := resp.Header.Get("route-version")
602-
if name == dp.latestRouteVersion {
603-
return false
604-
}
605-
dp.latestRouteVersion = name
606-
return true
600+
return name == expectedVersion
607601
}
608602

609603
func (dp *DataPlane) FlushCoverage() error {

0 commit comments

Comments
 (0)