/
drmaa2_test.go
61 lines (57 loc) · 1.63 KB
/
drmaa2_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package drmaa2_test
import (
"github.com/dgruber/drmaa2"
"testing"
)
// Tests if MonitoringSession can be opened and closed.
// Requires the libdrmaa2.so in $LD_LIBRARY_PATH.
func TestOpenMonitoringSession(t *testing.T) {
// Simple test for open and closing as MonitoringSession
var sm drmaa2.SessionManager
ms, err := sm.OpenMonitoringSession("")
if err != nil {
t.Errorf("Couldn't open Monitoring session. %s", err)
if ms != nil {
t.Errorf("MonitoringSession needs to be nil in case of error")
}
return
}
t.Log("OpenMonitoringSession() created a MonitoringSession succesfully")
if err := ms.CloseMonitoringSession(); err != nil {
t.Errorf("CloseMonitoringSession() returned error: %s", err)
}
}
func TestMonitoringSessionGetAllMachines(t *testing.T) {
var sm drmaa2.SessionManager
ms, err := sm.OpenMonitoringSession("")
if err != nil {
t.Errorf("Couldn't open Monitoring session. %s", err)
if ms != nil {
t.Errorf("MonitoringSession needs to be nil in case of error")
}
return
}
// get all machines
if machine, err := ms.GetAllMachines(nil); err != nil {
t.Errorf("Error during GetAllMachines(nil): ", err)
return
} else {
amount := len(machine)
if amount < 1 {
t.Errorf("Error: No machine returned in GetAllMachines(nil)", err)
}
// get a single machine
names := make([]string, 0)
names = append(names, machine[0].Name)
if machine2, err := ms.GetAllMachines(names); err != nil {
t.Errorf("Error in GetAllMachines(string).", err)
} else {
if len(machine2) != 1 {
t.Error("Filter for machines in GetAllMachines([]string) seems not to work")
return
}
}
}
return
}
// TODO add more :)