mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-07-27 06:36:07 +02:00
Fix broken schema and add tests
This commit is contained in:
80
pkg/schema/validate_test.go
Normal file
80
pkg/schema/validate_test.go
Normal file
@@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
package schema
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateConfig(t *testing.T) {
|
||||
json := []byte(`{
|
||||
"clusters": [
|
||||
{
|
||||
"name": "testcluster",
|
||||
"metricDataRepository": {
|
||||
"kind": "cc-metric-store",
|
||||
"url": "localhost:8082"},
|
||||
"filterRanges": {
|
||||
"numNodes": { "from": 1, "to": 64 },
|
||||
"duration": { "from": 0, "to": 86400 },
|
||||
"startTime": { "from": "2022-01-01T00:00:00Z", "to": null }
|
||||
}
|
||||
}
|
||||
]
|
||||
}`)
|
||||
|
||||
if err := Validate(Config, bytes.NewReader(json)); err != nil {
|
||||
t.Errorf("Error is not nil! %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateJobMeta(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestValidateCluster(t *testing.T) {
|
||||
json := []byte(`{
|
||||
"name": "emmy",
|
||||
"subClusters": [
|
||||
{
|
||||
"name": "main",
|
||||
"processorType": "Intel IvyBridge",
|
||||
"socketsPerNode": 2,
|
||||
"coresPerSocket": 10,
|
||||
"threadsPerCore": 2,
|
||||
"flopRateScalar": 44,
|
||||
"flopRateSimd": 704,
|
||||
"memoryBandwidth": 80,
|
||||
"topology": {
|
||||
"node": [0,20,1,21,2,22,3,23,4,24,5,25,6,26,7,27,8,28,9,29,10,30,11,31,12,32,13,33,14,34,15,35,16,36,17,37,18,38,19,39],
|
||||
"socket": [
|
||||
[0,20,1,21,2,22,3,23,4,24,5,25,6,26,7,27,8,28,9,29],
|
||||
[10,30,11,31,12,32,13,33,14,34,15,35,16,36,17,37,18,38,19,39]
|
||||
],
|
||||
"memoryDomain": [
|
||||
[0,20,1,21,2,22,3,23,4,24,5,25,6,26,7,27,8,28,9,29],
|
||||
[10,30,11,31,12,32,13,33,14,34,15,35,16,36,17,37,18,38,19,39]
|
||||
],
|
||||
"core": [
|
||||
[0,20],[1,21],[2,22],[3,23],[4,24],[5,25],[6,26],[7,27],[8,28],[9,29],[10,30],[11,31],[12,32],[13,33],[14,34],[15,35],[16,36],[17,37],[18,38],[19,39]
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"metricConfig": [
|
||||
{
|
||||
"name": "cpu_load",
|
||||
"scope": "hwthread",
|
||||
"unit": "load",
|
||||
"timestep": 60
|
||||
}
|
||||
]
|
||||
}`)
|
||||
|
||||
if err := Validate(ClusterCfg, bytes.NewReader(json)); err != nil {
|
||||
t.Errorf("Error is not nil! %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user