This commit is contained in:
Christoph Kluge
2026-01-30 17:22:42 +01:00
3 changed files with 36 additions and 21 deletions

View File

@@ -155,7 +155,7 @@ const configSchema = `{
} }
} }
}, },
"required": ["name", "sub-clusters"], "required": ["name"],
"minItems": 1 "minItems": 1
} }
} }

View File

@@ -80,7 +80,7 @@ var UIDefaults = WebConfig{
ShowFootprint: false, ShowFootprint: false,
}, },
NodeList: NodeListConfig{ NodeList: NodeListConfig{
UsePaging: true, UsePaging: false,
}, },
JobView: JobViewConfig{ JobView: JobViewConfig{
ShowPolarPlot: true, ShowPolarPlot: true,
@@ -89,8 +89,8 @@ var UIDefaults = WebConfig{
ShowStatTable: true, ShowStatTable: true,
}, },
MetricConfig: MetricConfig{ MetricConfig: MetricConfig{
JobListMetrics: []string{"flops_any", "mem_bw", "mem_used"}, JobListMetrics: []string{"cpu_load", "flops_any", "mem_bw", "mem_used"},
JobViewPlotMetrics: []string{"flops_any", "mem_bw", "mem_used"}, JobViewPlotMetrics: []string{"cpu_load", "flops_any", "mem_bw", "mem_used"},
JobViewTableMetrics: []string{"flops_any", "mem_bw", "mem_used"}, JobViewTableMetrics: []string{"flops_any", "mem_bw", "mem_used"},
}, },
PlotConfiguration: PlotConfiguration{ PlotConfiguration: PlotConfiguration{

View File

@@ -7,35 +7,48 @@ package web
import ( import (
"encoding/json" "encoding/json"
"fmt"
"testing" "testing"
ccconf "github.com/ClusterCockpit/cc-lib/v2/ccConfig"
) )
func TestInit(t *testing.T) { func TestInitDefaults(t *testing.T) {
fp := "../../configs/config.json" // Test Init with nil config uses defaults
ccconf.Init(fp) err := Init(nil)
cfg := ccconf.GetPackageConfig("ui") if err != nil {
t.Fatalf("Init failed: %v", err)
}
Init(cfg) // Check default values are set
if UIDefaultsMap["jobList_usePaging"] != false {
if UIDefaultsMap["nodeList_usePaging"] == false { t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["jobList_usePaging"])
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["NodeList_UsePaging"]) }
if UIDefaultsMap["nodeList_usePaging"] != false {
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["nodeList_usePaging"])
}
if UIDefaultsMap["jobView_showPolarPlot"] != true {
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["jobView_showPolarPlot"])
} }
} }
func TestSimpleDefaults(t *testing.T) { func TestSimpleDefaults(t *testing.T) {
const s = `{ const s = `{
"job-list": { "job-list": {
"show-footprint": false "show-footprint": true
} }
}` }`
Init(json.RawMessage(s)) err := Init(json.RawMessage(s))
if err != nil {
t.Fatalf("Init failed: %v", err)
}
if UIDefaultsMap["jobList_usePaging"] == true { // Verify show-footprint was set
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["NodeList_UsePaging"]) if UIDefaultsMap["jobList_showFootprint"] != true {
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["jobList_showFootprint"])
}
// Verify other defaults remain unchanged
if UIDefaultsMap["jobList_usePaging"] != false {
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["jobList_usePaging"])
} }
} }
@@ -59,9 +72,11 @@ func TestOverwrite(t *testing.T) {
} }
}` }`
Init(json.RawMessage(s)) err := Init(json.RawMessage(s))
if err != nil {
t.Fatalf("Init failed: %v", err)
}
fmt.Printf("%+v", UIDefaultsMap)
v, ok := UIDefaultsMap["metricConfig_jobListMetrics"].([]string) v, ok := UIDefaultsMap["metricConfig_jobListMetrics"].([]string)
if ok { if ok {
if v[0] != "flops_sp" { if v[0] != "flops_sp" {