From a168efa8c8cde4e9acac40ce28bd6f0d9df311af Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Wed, 22 Mar 2023 07:05:41 +0100 Subject: [PATCH] Fix unit tests --- .gitignore | 1 + pkg/archive/fsBackend_test.go | 2 +- pkg/schema/validate_test.go | 33 +++++++++++++++--- pkg/units/units_test.go | 4 +-- test/integration_test.go | 63 ++++++++++++++++++++++++++++++----- 5 files changed, 88 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 36b051f..11722c8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /web/frontend/public/build /web/frontend/node_modules .vscode/settings.json +sanitize-archive diff --git a/pkg/archive/fsBackend_test.go b/pkg/archive/fsBackend_test.go index 962aa23..8d37b6f 100644 --- a/pkg/archive/fsBackend_test.go +++ b/pkg/archive/fsBackend_test.go @@ -141,7 +141,7 @@ func TestLoadCluster(t *testing.T) { t.Fatal(err) } - if cfg.SubClusters[0].CoresPerSocket != 10 { + if cfg.SubClusters[0].CoresPerSocket != 4 { t.Fail() } } diff --git a/pkg/schema/validate_test.go b/pkg/schema/validate_test.go index 465ddd0..1bd1850 100644 --- a/pkg/schema/validate_test.go +++ b/pkg/schema/validate_test.go @@ -45,9 +45,29 @@ func TestValidateCluster(t *testing.T) { "socketsPerNode": 2, "coresPerSocket": 10, "threadsPerCore": 2, - "flopRateScalar": 44, - "flopRateSimd": 704, - "memoryBandwidth": 80, + "flopRateScalar": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 14 + }, + "flopRateSimd": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 112 + }, + "memoryBandwidth": { + "unit": { + "prefix": "G", + "base": "B/s" + }, + "value": 24 + }, + "numberOfNodes": 70, + "nodes": "w11[27-45,49-63,69-72]", "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": [ @@ -69,7 +89,12 @@ func TestValidateCluster(t *testing.T) { "name": "cpu_load", "scope": "hwthread", "unit": {"base": "load"}, - "timestep": 60 + "aggregation": "avg", + "timestep": 60, + "peak": 4, + "normal": 2, + "caution": 1, + "alert": 0.25 } ] }`) diff --git a/pkg/units/units_test.go b/pkg/units/units_test.go index cf0bce4..078a6a0 100644 --- a/pkg/units/units_test.go +++ b/pkg/units/units_test.go @@ -251,8 +251,8 @@ func TestNormalizeValueNoPrefix(t *testing.T) { if v != 104.00 { t.Errorf("Failed ConvertValue: Want 104.00, Got %f", v) } - if s != "MFlops/s" { - t.Errorf("Failed Prefix or unit: Want GB/s, Got %s", s) + if s != "MF/s" { + t.Errorf("Failed Prefix or unit: Want MF/s, Got %s", s) } } diff --git a/test/integration_test.go b/test/integration_test.go index 1e2ef17..d438883 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -69,9 +69,28 @@ func setup(t *testing.T) *api.RestApi { "socketsPerNode": 1, "coresPerSocket": 4, "threadsPerCore": 2, - "flopRateScalar": 44, - "flopRateSimd": 704, - "memoryBandwidth": 80, + "flopRateScalar": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 14 + }, + "flopRateSimd": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 112 + }, + "memoryBandwidth": { + "unit": { + "prefix": "G", + "base": "B/s" + }, + "value": 24 + }, + "numberOfNodes": 70, "topology": { "node": [0, 1, 2, 3, 4, 5, 6, 7], "socket": [[0, 1, 2, 3, 4, 5, 6, 7]], @@ -87,6 +106,7 @@ func setup(t *testing.T) *api.RestApi { "unit": { "base": "load"}, "scope": "node", "timestep": 60, + "aggregation": "avg", "peak": 8, "normal": 0, "caution": 0, @@ -103,10 +123,30 @@ func setup(t *testing.T) *api.RestApi { "processorType": "Intel Haswell", "socketsPerNode": 2, "coresPerSocket": 12, - "threadsPerCore": 1, - "flopRateScalar": 32, - "flopRateSimd": 512, - "memoryBandwidth": 60, + "threadsPerCore": 1, + "flopRateScalar": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 14 + }, + "flopRateSimd": { + "unit": { + "prefix": "G", + "base": "F/s" + }, + "value": 112 + }, + "memoryBandwidth": { + "unit": { + "prefix": "G", + "base": "B/s" + }, + "value": 24 + }, + "numberOfNodes": 70, + "nodes": "w11[27-45,49-63,69-72]", "topology": { "node": [ 0, 1 ], "socket": [ @@ -126,6 +166,7 @@ func setup(t *testing.T) *api.RestApi { "name": "cpu_used", "scope": "core", "unit": {"base": ""}, + "aggregation": "avg", "timestep": 30, "subClusters": [ { @@ -141,6 +182,7 @@ func setup(t *testing.T) *api.RestApi { "name": "ipc", "scope": "core", "unit": { "base": "IPC"}, + "aggregation": "avg", "timestep": 60, "subClusters": [ { @@ -156,6 +198,7 @@ func setup(t *testing.T) *api.RestApi { "name": "flops_any", "scope": "core", "unit": { "base": "F/s"}, + "aggregation": "sum", "timestep": 60, "subClusters": [ { @@ -171,6 +214,7 @@ func setup(t *testing.T) *api.RestApi { "name": "mem_bw", "scope": "socket", "unit": { "base": "B/s"}, + "aggregation": "sum", "timestep": 60, "subClusters": [ { @@ -186,6 +230,7 @@ func setup(t *testing.T) *api.RestApi { "name": "file_bw", "scope": "node", "unit": { "base": "B/s"}, + "aggregation": "sum", "timestep": 30, "subClusters": [ { @@ -216,6 +261,7 @@ func setup(t *testing.T) *api.RestApi { "name": "mem_used", "scope": "node", "unit": {"base": "B"}, + "aggregation": "sum", "timestep": 30, "subClusters": [ { @@ -231,6 +277,7 @@ func setup(t *testing.T) *api.RestApi { "name": "cpu_power", "scope": "socket", "unit": {"base": "W"}, + "aggregation": "sum", "timestep": 60, "subClusters": [ { @@ -605,7 +652,7 @@ func testImportFlag(t *testing.T) { r := map[string]string{"mem_used": "GB", "net_bw": "KB/s", "cpu_power": "W", "cpu_used": "", - "file_bw": "KB/s", "flops_any": "Flops/s", + "file_bw": "KB/s", "flops_any": "F/s", "mem_bw": "GB/s", "ipc": "IPC"} for name, scopes := range data {