Skip to content

Commit

Permalink
Fix permission, showcase config in access logger
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
  • Loading branch information
mathetake committed Mar 15, 2021
1 parent b3c33e1 commit db99b4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (l *accessLogger) OnLog() {
return
}

proxywasm.LogInfof("OnLog: :path = %s", hdr)
proxywasm.LogInfof(":path = %s", hdr)
proxywasm.LogInfof("message = %s", l.logMessage)

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@ import (
)

func TestAccessLogger_OnLog(t *testing.T) {
configuration := `this is my log message`
opt := proxytest.NewEmulatorOption().
WithNewRootContext(newAccessLogger)
WithNewRootContext(newAccessLogger).
WithPluginConfiguration([]byte(configuration))

host := proxytest.NewHostEmulator(opt)
// Release the host emulation lock so that other test cases can insert their own host emulation.
defer host.Done()

// Call OnPluginStart -> the message field of root context is configured.
status := host.StartPlugin()
// Check the status returned by OnPluginStart is OK.
require.Equal(t, types.OnPluginStartStatusOK, status)

// Call OnLog with the given headers.
host.CallOnLogForAccessLogger(types.Headers{
{":path", "/this/is/path"},
}, nil)

// Check the Envoy logs.
logs := host.GetLogs(types.LogLevelInfo)
require.Contains(t, logs, "OnLog: :path = /this/is/path")
require.Contains(t, logs, ":path = /this/is/path")
require.Contains(t, logs, "message = this is my log message")
}
4 changes: 2 additions & 2 deletions images/extension-builders/tinygo/commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ extension_build() {
tinygo build -o "$1" -scheduler=none -target wasi main.go
# This is necessary since the created go caches are with read-only permission,
# and without this, the host user cannot delete the build directory with "rm -rf".
chmod -R a+rw build/
chmod -R u+rw build/
}

extension_test() {
go test -tags=proxytest -v ./...
# This is necessary since the created go caches are with read-only permission,
# and without this, the host user cannot delete the build directory with "rm -rf".
chmod -R a+rw build/
chmod -R u+rw build/
}

extension_clean() {
Expand Down

0 comments on commit db99b4a

Please sign in to comment.