-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm integration tests for local and remote wasm files
refactoring and cleanup for wasm testing remove wasm debug logging PR feedback, wasm build lock correct path pattern for wasm build files Add new helper function to minimize changes to existing test code Remove extra param mod tidy add custom service setup to test lib
- Loading branch information
Showing
12 changed files
with
913 additions
and
9 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
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
13 changes: 13 additions & 0 deletions
13
test/integration/consul-container/test/envoy_extensions/testdata/wasm_test_files/go.mod
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,13 @@ | ||
module main | ||
|
||
go 1.20 | ||
|
||
require ( | ||
github.com/tetratelabs/proxy-wasm-go-sdk v0.21.0 | ||
github.com/tidwall/gjson v1.14.4 | ||
) | ||
|
||
require ( | ||
github.com/tidwall/match v1.1.1 // indirect | ||
github.com/tidwall/pretty v1.2.0 // indirect | ||
) |
12 changes: 12 additions & 0 deletions
12
test/integration/consul-container/test/envoy_extensions/testdata/wasm_test_files/go.sum
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,12 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||
github.com/tetratelabs/proxy-wasm-go-sdk v0.21.0 h1:sxuh1wxy/zz4vXwMEC+ESVpwJmej1f22eYsrJlgVn7c= | ||
github.com/tetratelabs/proxy-wasm-go-sdk v0.21.0/go.mod h1:jqQTUvJBI6WJ+sVCZON3A4GwmUfBDuiNnZ4kuxsvLCo= | ||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= | ||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= | ||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= | ||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= | ||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= | ||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
13 changes: 13 additions & 0 deletions
13
test/integration/consul-container/test/envoy_extensions/testdata/wasm_test_files/nginx.conf
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,13 @@ | ||
server { | ||
# send wasm files as download rather than render as html | ||
location ~ ^.*/(?P<request_basename>[^/]+\.(wasm))$ { | ||
root /www/downloads; | ||
|
||
add_header Content-disposition 'attachment; filename="$request_basename"'; | ||
types { | ||
application/octet-stream .wasm; | ||
} | ||
default_type application/octet-stream; | ||
} | ||
} | ||
|
47 changes: 47 additions & 0 deletions
47
...ration/consul-container/test/envoy_extensions/testdata/wasm_test_files/wasm_add_header.go
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,47 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm" | ||
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" | ||
) | ||
|
||
func main() { | ||
proxywasm.SetVMContext(&vmContext{}) | ||
} | ||
|
||
type vmContext struct { | ||
// Embed the default VM context here, | ||
// so that we don't need to reimplement all the methods. | ||
types.DefaultVMContext | ||
} | ||
|
||
func (*vmContext) NewPluginContext(contextID uint32) types.PluginContext { | ||
return &pluginContext{} | ||
} | ||
|
||
type pluginContext struct { | ||
// Embed the default plugin context here, | ||
// so that we don't need to reimplement all the methods. | ||
types.DefaultPluginContext | ||
} | ||
|
||
func (p *pluginContext) NewHttpContext(contextID uint32) types.HttpContext { | ||
return &httpHeaders{} | ||
} | ||
|
||
type httpHeaders struct { | ||
// Embed the default http context here, | ||
// so that we don't need to reimplement all the methods. | ||
types.DefaultHttpContext | ||
} | ||
|
||
func (ctx *httpHeaders) OnHttpResponseHeaders(int, bool) types.Action { | ||
proxywasm.LogDebug("adding header: x-test:true") | ||
|
||
err := proxywasm.AddHttpResponseHeader("x-test", "true") | ||
if err != nil { | ||
proxywasm.LogCriticalf("failed to add test header to response: %v", err) | ||
} | ||
|
||
return types.ActionContinue | ||
} |
Oops, something went wrong.