-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more methods to control bootstrap config
Signed-off-by: spacewander <[email protected]>
- Loading branch information
1 parent
982b45c
commit 00e4670
Showing
4 changed files
with
169 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dataplane | ||
|
||
import ( | ||
"bytes" | ||
_ "embed" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var ( | ||
//go:embed testdata/listener.yml | ||
listener string | ||
) | ||
|
||
func TestInsertHTTPFilterBeforeRouter(t *testing.T) { | ||
dp := &DataPlane{ | ||
t: t, | ||
opt: &Option{}, | ||
} | ||
b := Bootstrap() | ||
b.SetDataPlane(dp) | ||
b.InsertHTTPFilter(map[string]interface{}{ | ||
"name": "test.filter.buffer", | ||
"typed_config": map[string]interface{}{ | ||
"@type": "type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer", | ||
"max_request_bytes": 1024, | ||
}, | ||
}, HTTPFilterInsertOperationBeforeRouter) | ||
buf := bytes.NewBuffer([]byte("")) | ||
err := b.WriteTo(buf) | ||
assert.Nil(t, err) | ||
assert.Regexp(t, `- name: test.filter.buffer\s+typed_config:[^-]+- name: envoy.filters.http.router`, buf.String()) | ||
} | ||
|
||
func TestAddListener(t *testing.T) { | ||
dp := &DataPlane{ | ||
t: t, | ||
opt: &Option{}, | ||
} | ||
b := Bootstrap() | ||
b.SetDataPlane(dp) | ||
b.AddListener(listener) | ||
buf := bytes.NewBuffer([]byte("")) | ||
err := b.WriteTo(buf) | ||
assert.Nil(t, err) | ||
s := buf.String() | ||
assert.Contains(t, s, "name: listener_proxy") | ||
assert.Contains(t, s, "cluster: x_backend") | ||
} |
29 changes: 29 additions & 0 deletions
29
api/plugins/tests/integration/dataplane/testdata/listener.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: listener_proxy | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 10010 | ||
filter_chains: | ||
- filters: | ||
- name: envoy.filters.network.http_connection_manager | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | ||
stat_prefix: ingress_http | ||
access_log: | ||
- name: envoy.access_loggers.stdout | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog | ||
http_filters: | ||
- name: envoy.filters.http.router | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router | ||
route_config: | ||
name: local_route | ||
virtual_hosts: | ||
- name: local_service | ||
domains: ["*"] | ||
routes: | ||
- match: | ||
prefix: / | ||
route: | ||
cluster: x_backend |