mirror of
https://github.com/coder/coder.git
synced 2025-07-23 21:32:07 +00:00
feat: Enable workspace debug logging (#6838)
* feat: Enable workspace debug logging * Fix * Fix * Fix * fix * fix * Enable RBAC * unit tests * Fix * fix * fix * fix * more tests * fix: workspacebuild_test use roles * fix: swagger comment * fix: ctx.Done * fix: address PR comments * break loop
This commit is contained in:
@ -79,6 +79,7 @@ func TestEcho(t *testing.T) {
|
||||
responses := []*proto.Provision_Response{{
|
||||
Type: &proto.Provision_Response_Log{
|
||||
Log: &proto.Log{
|
||||
Level: proto.LogLevel_INFO,
|
||||
Output: "log-output",
|
||||
},
|
||||
},
|
||||
@ -115,6 +116,59 @@ func TestEcho(t *testing.T) {
|
||||
require.Equal(t, responses[1].GetComplete().Resources[0].Name,
|
||||
complete.GetComplete().Resources[0].Name)
|
||||
})
|
||||
|
||||
t.Run("ProvisionWithLogLevel", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
responses := []*proto.Provision_Response{{
|
||||
Type: &proto.Provision_Response_Log{
|
||||
Log: &proto.Log{
|
||||
Level: proto.LogLevel_TRACE,
|
||||
Output: "log-output-trace",
|
||||
},
|
||||
},
|
||||
}, {
|
||||
Type: &proto.Provision_Response_Log{
|
||||
Log: &proto.Log{
|
||||
Level: proto.LogLevel_INFO,
|
||||
Output: "log-output-info",
|
||||
},
|
||||
},
|
||||
}, {
|
||||
Type: &proto.Provision_Response_Complete{
|
||||
Complete: &proto.Provision_Complete{
|
||||
Resources: []*proto.Resource{{
|
||||
Name: "resource",
|
||||
}},
|
||||
},
|
||||
},
|
||||
}}
|
||||
data, err := echo.Tar(&echo.Responses{
|
||||
ProvisionApply: responses,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
client, err := api.Provision(ctx)
|
||||
require.NoError(t, err)
|
||||
err = client.Send(&proto.Provision_Request{
|
||||
Type: &proto.Provision_Request_Plan{
|
||||
Plan: &proto.Provision_Plan{
|
||||
Config: &proto.Provision_Config{
|
||||
Directory: unpackTar(t, fs, data),
|
||||
ProvisionerLogLevel: "debug",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
log, err := client.Recv()
|
||||
require.NoError(t, err)
|
||||
// Skip responses[0] as it's trace level
|
||||
require.Equal(t, responses[1].GetLog().Output, log.GetLog().Output)
|
||||
complete, err := client.Recv()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, responses[2].GetComplete().Resources[0].Name,
|
||||
complete.GetComplete().Resources[0].Name)
|
||||
})
|
||||
}
|
||||
|
||||
func unpackTar(t *testing.T, fs afero.Fs, data []byte) string {
|
||||
|
Reference in New Issue
Block a user