Skip to content

Commit

Permalink
include gpus_test data
Browse files Browse the repository at this point in the history
  • Loading branch information
itzsimpl committed Mar 24, 2022
1 parent 59504f5 commit d8c9c54
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 0 deletions.
63 changes: 63 additions & 0 deletions gpus_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright 2022 Iztok Lebar Bajec
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

package main

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
)

func TestGPUsMetrics(t *testing.T) {
test_data_paths, _ := filepath.Glob("test_data/slurm-*")
for _, test_data_path := range test_data_paths {
slurm_version := strings.TrimPrefix(test_data_path, "test_data/slurm-")
t.Logf("slurm-%s", slurm_version)

// Read the input data from a file
file, err := os.Open(test_data_path + "/sinfo_gpus_allocated.txt")
if err != nil {
t.Fatalf("Can not open test data: %v", err)
}
data, _ := ioutil.ReadAll(file)
metrics := ParseAllocatedGPUs(data)
t.Logf("Allocated: %+v", metrics)

// Read the input data from a file
file, err = os.Open(test_data_path + "/sinfo_gpus_idle.txt")
if err != nil {
t.Fatalf("Can not open test data: %v", err)
}
data, _ = ioutil.ReadAll(file)
metrics = ParseIdleGPUs(data)
t.Logf("Idle: %+v", metrics)

// Read the input data from a file
file, err = os.Open(test_data_path + "/sinfo_gpus_total.txt")
if err != nil {
t.Fatalf("Can not open test data: %v", err)
}
data, _ = ioutil.ReadAll(file)
metrics = ParseTotalGPUs(data)
t.Logf("Total: %+v", metrics)
}
}

func TestGPUsGetMetrics(t *testing.T) {
t.Logf("%+v", GPUsGetMetrics())
}
5 changes: 5 additions & 0 deletions test_data/_slurm-17.11.2/sacct_gpus_allocated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gpu:4
gpu:7
gpu:1
gpu:1
gpu:1
2 changes: 2 additions & 0 deletions test_data/_slurm-17.11.2/sinfo_gpus_total.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
xantipa gpu:8
xantipa2 gpu:8
3 changes: 3 additions & 0 deletions test_data/slurm-20.11.8/sinfo_gpus_allocated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
98 gpu:0
3 gpu:2
1 gpu:1
4 changes: 4 additions & 0 deletions test_data/slurm-20.11.8/sinfo_gpus_idle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
99 (null) gpu:0
3 gpu:2 gpu:2
1 gpu:2 gpu:1
20 gpu:2 gpu:0
2 changes: 2 additions & 0 deletions test_data/slurm-20.11.8/sinfo_gpus_total.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
101 (null)
24 gpu:2
Empty file.
1 change: 1 addition & 0 deletions test_data/slurm-21.08.5/sinfo_gpus_idle.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 gpu:8 gpu:(null):0(IDX:N/A)
1 change: 1 addition & 0 deletions test_data/slurm-21.08.5/sinfo_gpus_total.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2 gpu:8

0 comments on commit d8c9c54

Please sign in to comment.