Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed integration test for ads #440

Merged
merged 2 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions pkg/server/v3/delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,81 @@ func TestDeltaAggregatedHandlers(t *testing.T) {
}
}
}

func TestDeltaAggregateRequestType(t *testing.T) {
config := makeMockConfigWatcher()
s := server.NewServer(context.Background(), config, server.CallbackFuncs{})
resp := makeMockDeltaStream(t)
resp.recv <- &discovery.DeltaDiscoveryRequest{Node: node}
if err := s.DeltaAggregatedResources(resp); err == nil {
t.Error("DeltaAggregatedResources() => got nil, want an error")
}
}

func TestDeltaCancellations(t *testing.T) {
config := makeMockConfigWatcher()
resp := makeMockDeltaStream(t)
for _, typ := range testTypes {
resp.recv <- &discovery.DeltaDiscoveryRequest{
Node: node,
TypeUrl: typ,
}
}
close(resp.recv)
s := server.NewServer(context.Background(), config, server.CallbackFuncs{})
if err := s.DeltaAggregatedResources(resp); err != nil {
t.Errorf("DeltaAggregatedResources() => got %v, want no error", err)
}
if config.watches != 0 {
t.Errorf("Expect all watches cancelled, got %q", config.watches)
}
}

func TestDeltaOpaqueRequestsChannelMuxing(t *testing.T) {
config := makeMockConfigWatcher()
resp := makeMockDeltaStream(t)
for i := 0; i < 10; i++ {
resp.recv <- &discovery.DeltaDiscoveryRequest{
Node: node,
TypeUrl: fmt.Sprintf("%s%d", opaqueType, i%2),
ResourceNamesSubscribe: []string{fmt.Sprintf("%d", i)},
}
}
close(resp.recv)
s := server.NewServer(context.Background(), config, server.CallbackFuncs{})
if err := s.DeltaAggregatedResources(resp); err != nil {
t.Errorf("DeltaAggregatedResources() => got %v, want no error", err)
}
if config.watches != 0 {
t.Errorf("Expect all watches cancelled, got %q", config.watches)
}
}

func TestDeltaCallbackError(t *testing.T) {
for _, typ := range testTypes {
t.Run(typ, func(t *testing.T) {
config := makeMockConfigWatcher()
config.deltaResponses = makeDeltaResponses()

s := server.NewServer(context.Background(), config, server.CallbackFuncs{
DeltaStreamOpenFunc: func(ctx context.Context, i int64, s string) error {
return errors.New("stream open error")
},
})

// make a request
resp := makeMockDeltaStream(t)
resp.recv <- &discovery.DeltaDiscoveryRequest{
Node: node,
TypeUrl: typ,
}

// check that response fails since stream open returns error
if err := s.DeltaAggregatedResources(resp); err == nil {
t.Error("Stream() => got no error, want error")
}

close(resp.recv)
})
}
}
4 changes: 2 additions & 2 deletions pkg/server/v3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (c CallbackFuncs) OnStreamClosed(streamID int64) {

// OnDeltaStreamOpen invokes DeltaStreamOpenFunc.
func (c CallbackFuncs) OnDeltaStreamOpen(ctx context.Context, streamID int64, typeURL string) error {
if c.StreamOpenFunc != nil {
if c.DeltaStreamOpenFunc != nil {
return c.DeltaStreamOpenFunc(ctx, streamID, typeURL)
}

Expand All @@ -104,7 +104,7 @@ func (c CallbackFuncs) OnDeltaStreamOpen(ctx context.Context, streamID int64, ty

// OnDeltaStreamClosed invokes DeltaStreamClosedFunc.
func (c CallbackFuncs) OnDeltaStreamClosed(streamID int64) {
if c.StreamClosedFunc != nil {
if c.DeltaStreamClosedFunc != nil {
c.DeltaStreamClosedFunc(streamID)
}
}
Expand Down
16 changes: 1 addition & 15 deletions sample/bootstrap-delta-ads.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,4 @@ static_resources:
address: 127.0.0.1
port_value: 18000
http2_protocol_options: {}
name: xds_cluster
layered_runtime:
layers:
- name: runtime-0
rtds_layer:
rtds_config:
resource_api_version: V3
ads: {}
name: runtime-0
- name: runtime-1
rtds_layer:
rtds_config:
resource_api_version: V3
ads: {}
name: runtime-1
Comment on lines -38 to -52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you file an issue to look into this? I don't see why this shouldn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snowp sure thing, do you want an issue in Envoy as well? Or just in the control-plane code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it here for now until we can figure out what's wrong. Would be great if you could include the logs you got earlier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay cool I'll file an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name: xds_cluster