File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed
data/extension/init/templates/tinygo/envoy.access_loggers/default
images/extension-builders/tinygo Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ func (l *accessLogger) OnLog() {
4040 return
4141 }
4242
43- proxywasm .LogInfof ("OnLog: :path = %s" , hdr )
43+ proxywasm .LogInfof (":path = %s" , hdr )
4444 proxywasm .LogInfof ("message = %s" , l .logMessage )
4545
4646}
Original file line number Diff line number Diff line change @@ -10,18 +10,27 @@ import (
1010)
1111
1212func TestAccessLogger_OnLog (t * testing.T ) {
13+ configuration := `this is my log message`
1314 opt := proxytest .NewEmulatorOption ().
14- WithNewRootContext (newAccessLogger )
15+ WithNewRootContext (newAccessLogger ).
16+ WithPluginConfiguration ([]byte (configuration ))
17+
1518 host := proxytest .NewHostEmulator (opt )
1619 // Release the host emulation lock so that other test cases can insert their own host emulation.
1720 defer host .Done ()
1821
22+ // Call OnPluginStart -> the message field of root context is configured.
23+ status := host .StartPlugin ()
24+ // Check the status returned by OnPluginStart is OK.
25+ require .Equal (t , types .OnPluginStartStatusOK , status )
26+
1927 // Call OnLog with the given headers.
2028 host .CallOnLogForAccessLogger (types.Headers {
2129 {":path" , "/this/is/path" },
2230 }, nil )
2331
2432 // Check the Envoy logs.
2533 logs := host .GetLogs (types .LogLevelInfo )
26- require .Contains (t , logs , "OnLog: :path = /this/is/path" )
34+ require .Contains (t , logs , ":path = /this/is/path" )
35+ require .Contains (t , logs , "message = this is my log message" )
2736}
Original file line number Diff line number Diff line change @@ -18,14 +18,14 @@ extension_build() {
1818 tinygo build -o " $1 " -scheduler=none -target wasi main.go
1919 # This is necessary since the created go caches are with read-only permission,
2020 # and without this, the host user cannot delete the build directory with "rm -rf".
21- chmod -R a +rw build/
21+ chmod -R u +rw build/
2222}
2323
2424extension_test () {
2525 go test -tags=proxytest -v ./...
2626 # This is necessary since the created go caches are with read-only permission,
2727 # and without this, the host user cannot delete the build directory with "rm -rf".
28- chmod -R a +rw build/
28+ chmod -R u +rw build/
2929}
3030
3131extension_clean () {
You can’t perform that action at this time.
0 commit comments