mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-31 08:11:45 +01:00
Merge branch 'dev' of https://github.com/ClusterCockpit/cc-backend into dev
This commit is contained in:
@@ -155,7 +155,7 @@ const configSchema = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["name", "sub-clusters"],
|
||||
"required": ["name"],
|
||||
"minItems": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ var UIDefaults = WebConfig{
|
||||
ShowFootprint: false,
|
||||
},
|
||||
NodeList: NodeListConfig{
|
||||
UsePaging: true,
|
||||
UsePaging: false,
|
||||
},
|
||||
JobView: JobViewConfig{
|
||||
ShowPolarPlot: true,
|
||||
@@ -89,8 +89,8 @@ var UIDefaults = WebConfig{
|
||||
ShowStatTable: true,
|
||||
},
|
||||
MetricConfig: MetricConfig{
|
||||
JobListMetrics: []string{"flops_any", "mem_bw", "mem_used"},
|
||||
JobViewPlotMetrics: []string{"flops_any", "mem_bw", "mem_used"},
|
||||
JobListMetrics: []string{"cpu_load", "flops_any", "mem_bw", "mem_used"},
|
||||
JobViewPlotMetrics: []string{"cpu_load", "flops_any", "mem_bw", "mem_used"},
|
||||
JobViewTableMetrics: []string{"flops_any", "mem_bw", "mem_used"},
|
||||
},
|
||||
PlotConfiguration: PlotConfiguration{
|
||||
|
||||
@@ -7,35 +7,48 @@ package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
ccconf "github.com/ClusterCockpit/cc-lib/v2/ccConfig"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
fp := "../../configs/config.json"
|
||||
ccconf.Init(fp)
|
||||
cfg := ccconf.GetPackageConfig("ui")
|
||||
func TestInitDefaults(t *testing.T) {
|
||||
// Test Init with nil config uses defaults
|
||||
err := Init(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Init failed: %v", err)
|
||||
}
|
||||
|
||||
Init(cfg)
|
||||
|
||||
if UIDefaultsMap["nodeList_usePaging"] == false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: true", UIDefaultsMap["NodeList_UsePaging"])
|
||||
// Check default values are set
|
||||
if UIDefaultsMap["jobList_usePaging"] != false {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["jobList_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) {
|
||||
const s = `{
|
||||
"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 {
|
||||
t.Errorf("wrong option\ngot: %v \nwant: false", UIDefaultsMap["NodeList_UsePaging"])
|
||||
// Verify show-footprint was set
|
||||
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)
|
||||
if ok {
|
||||
if v[0] != "flops_sp" {
|
||||
|
||||
Reference in New Issue
Block a user