mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 13:29:05 +01:00
81 lines
1.9 KiB
Go
81 lines
1.9 KiB
Go
|
// 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)
|
||
|
}
|
||
|
}
|