Connection logs now record how a connection was made (`connection_method`) separately from which app made it (`app_name`). Storage, the HTTP API, search filters, and the UI move to the new fields. Legacy agent reports and the deprecated `type` field keep working. - Add `connection_method` (`ssh`, `reconnecting_pty`, `workspace_app`, `port_forwarding`, `tunnel`) and optional `app_name` and `app_display_name` to `GET /api/v2/connectionlog`. Deprecate `type` and make it a plain string in the API and the Go SDK. - Add `method:` and repeatable `app:` search filters. `type:` keeps its old results but can't be combined with the new filters. - Replace the Type menu with a Method menu, show the app next to the method in each row, and warn when a filter uses `type:`. - Change the Active SSH connections preset to `method:ssh`, so it also includes SSH sessions from VS Code and JetBrains apps. - Generate `codersdk.ConnectionLogMethod` from the database enum with `typegen dbenums`. - Migration 000617 rewrites `connection_logs` under an ACCESS EXCLUSIVE lock, which takes about 50 seconds for 10 million rows. `vscode` and `jetbrains` rows become `ssh` rows with that app. Rolling back folds apps into the old types and loses per-app names. - Document the new filters and how to replace each `type:` value. Closes #27412
27 lines
684 B
Go
27 lines
684 B
Go
package coderd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/v2/coderd/database"
|
|
)
|
|
|
|
// convertConnectionLog panics on a method it does not handle, so every method
|
|
// must convert with exactly one of WebInfo and SSHInfo.
|
|
func TestConvertConnectionLogHandlesEveryMethod(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for _, method := range database.AllConnectionLogMethodValues() {
|
|
t.Run(string(method), func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
log := convertConnectionLog(database.GetConnectionLogsOffsetRow{
|
|
ConnectionLog: database.ConnectionLog{ConnectionMethod: method},
|
|
})
|
|
require.NotEqual(t, log.WebInfo == nil, log.SSHInfo == nil)
|
|
})
|
|
}
|
|
}
|