MCPcopy Index your code
hub / github.com/coder/coder / TestVolumeResourceMonitor

Function TestVolumeResourceMonitor

coderd/agentapi/resources_monitoring_test.go:632–777  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

630}
631
632func TestVolumeResourceMonitor(t *testing.T) {
633 t.Parallel()
634
635 tests := []struct {
636 name string
637 volumePath string
638 volumeUsage []int64
639 volumeTotal int64
640 thresholdPercent int32
641 previousState database.WorkspaceAgentMonitorState
642 expectState database.WorkspaceAgentMonitorState
643 shouldNotify bool
644 }{
645 {
646 name: "WhenOK/NeverExceedsThreshold",
647 volumePath: "/home/coder",
648 volumeUsage: []int64{2, 3, 2, 4, 2, 3, 2, 1, 2, 3, 4, 4, 1, 2, 3, 1, 2},
649 volumeTotal: 10,
650 thresholdPercent: 80,
651 previousState: database.WorkspaceAgentMonitorStateOK,
652 expectState: database.WorkspaceAgentMonitorStateOK,
653 shouldNotify: false,
654 },
655 {
656 name: "WhenOK/ShouldStayInOK",
657 volumePath: "/home/coder",
658 volumeUsage: []int64{9, 3, 2, 4, 2, 3, 2, 1, 2, 3, 4, 4, 1, 2, 3, 1, 2},
659 volumeTotal: 10,
660 thresholdPercent: 80,
661 previousState: database.WorkspaceAgentMonitorStateOK,
662 expectState: database.WorkspaceAgentMonitorStateOK,
663 shouldNotify: false,
664 },
665 {
666 name: "WhenOK/ConsecutiveExceedsThreshold",
667 volumePath: "/home/coder",
668 volumeUsage: []int64{2, 3, 2, 4, 2, 3, 2, 1, 2, 3, 4, 4, 1, 8, 9, 8, 9},
669 volumeTotal: 10,
670 thresholdPercent: 80,
671 previousState: database.WorkspaceAgentMonitorStateOK,
672 expectState: database.WorkspaceAgentMonitorStateNOK,
673 shouldNotify: true,
674 },
675 {
676 name: "WhenOK/MinimumExceedsThreshold",
677 volumePath: "/home/coder",
678 volumeUsage: []int64{2, 8, 2, 9, 2, 8, 2, 9, 2, 8, 4, 9, 1, 8, 2, 8, 9},
679 volumeTotal: 10,
680 thresholdPercent: 80,
681 previousState: database.WorkspaceAgentMonitorStateOK,
682 expectState: database.WorkspaceAgentMonitorStateNOK,
683 shouldNotify: true,
684 },
685 {
686 name: "WhenNOK/NeverExceedsThreshold",
687 volumePath: "/home/coder",
688 volumeUsage: []int64{2, 3, 2, 4, 2, 3, 2, 1, 2, 3, 4, 4, 1, 2, 3, 1, 2},
689 volumeTotal: 10,

Callers

nothing calls this directly

Calls 12

WithTemplateIDFunction · 0.92
resourceMonitorAPIFunction · 0.85
InitMonitorsMethod · 0.80
SentMethod · 0.80
RunMethod · 0.65
AddMethod · 0.65
NewMethod · 0.65
SetMethod · 0.65
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected