mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
Make api test pass and cleanup
This commit is contained in:
parent
8fbd1b2cb8
commit
937e72954d
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
[
|
|
||||||
"name": "alex",
|
|
||||||
"metricDataRepository": {
|
|
||||||
"kind": "cc-metric-store",
|
|
||||||
"url": "http://localhost:8082",
|
|
||||||
"token": "eyJhbGciOiJF-E-pQBQ"
|
|
||||||
},
|
|
||||||
"filterRanges": {
|
|
||||||
"numNodes": { "from": 1, "to": 64 },
|
|
||||||
"duration": { "from": 0, "to": 86400 },
|
|
||||||
"startTime": { "from": "2022-01-01T00:00:00Z", "to": null }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"addr": "0.0.0.0:443",
|
"addr": "0.0.0.0:443",
|
||||||
"ldap": {
|
"ldap": {
|
||||||
"url": "ldaps://hpcldap.rrze.uni-erlangen.de",
|
"url": "ldaps://hpcldap.rrze.uni-erlangen.de",
|
||||||
"user_base": "ou=people,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
"user_base": "ou=people,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
||||||
"search_dn": "cn=hpcmonitoring,ou=roadm,ou=profile,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
"search_dn": "cn=hpcmonitoring,ou=roadm,ou=profile,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
||||||
"user_bind": "uid={username},ou=people,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
"user_bind": "uid={username},ou=people,ou=hpc,dc=rrze,dc=uni-erlangen,dc=de",
|
||||||
"user_filter": "(&(objectclass=posixAccount)(uid=*))"
|
"user_filter": "(&(objectclass=posixAccount)(uid=*))"
|
||||||
},
|
},
|
||||||
"https-cert-file": "/etc/letsencrypt/live/monitoring.nhr.fau.de/fullchain.pem",
|
"https-cert-file": "/etc/letsencrypt/live/monitoring.nhr.fau.de/fullchain.pem",
|
||||||
"https-key-file": "/etc/letsencrypt/live/monitoring.nhr.fau.de/privkey.pem",
|
"https-key-file": "/etc/letsencrypt/live/monitoring.nhr.fau.de/privkey.pem",
|
||||||
"user": "clustercockpit",
|
"user": "clustercockpit",
|
||||||
@ -14,5 +14,20 @@
|
|||||||
"archive": {
|
"archive": {
|
||||||
"kind": "file",
|
"kind": "file",
|
||||||
"path": "./var/job-archive"
|
"path": "./var/job-archive"
|
||||||
}
|
},
|
||||||
|
"clusters": [
|
||||||
|
{
|
||||||
|
"name": "test",
|
||||||
|
"metricDataRepository": {
|
||||||
|
"kind": "cc-metric-store",
|
||||||
|
"url": "http://localhost:8082",
|
||||||
|
"token": "eyJhbGciOiJF-E-pQBQ"
|
||||||
|
},
|
||||||
|
"filterRanges": {
|
||||||
|
"numNodes": { "from": 1, "to": 64 },
|
||||||
|
"duration": { "from": 0, "to": 86400 },
|
||||||
|
"startTime": { "from": "2022-01-01T00:00:00Z", "to": null }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ type ProgramConfig struct {
|
|||||||
StopJobsExceedingWalltime int `json:"stop-jobs-exceeding-walltime"`
|
StopJobsExceedingWalltime int `json:"stop-jobs-exceeding-walltime"`
|
||||||
|
|
||||||
// Array of Clusters
|
// Array of Clusters
|
||||||
Clusters []*Cluster `json:"Clusters"`
|
Clusters []*Cluster `json:"clusters"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var Keys ProgramConfig = ProgramConfig{
|
var Keys ProgramConfig = ProgramConfig{
|
||||||
@ -85,7 +85,7 @@ var Keys ProgramConfig = ProgramConfig{
|
|||||||
EmbedStaticFiles: true,
|
EmbedStaticFiles: true,
|
||||||
DBDriver: "sqlite3",
|
DBDriver: "sqlite3",
|
||||||
DB: "./var/job.db",
|
DB: "./var/job.db",
|
||||||
Archive: []byte(`{\"kind\":\"file\",\"path\":\"./var/job-archive\"}`),
|
Archive: json.RawMessage(`{\"kind\":\"file\",\"path\":\"./var/job-archive\"}`),
|
||||||
DisableArchive: false,
|
DisableArchive: false,
|
||||||
LdapConfig: nil,
|
LdapConfig: nil,
|
||||||
SessionMaxAge: "168h",
|
SessionMaxAge: "168h",
|
||||||
@ -113,7 +113,7 @@ var Keys ProgramConfig = ProgramConfig{
|
|||||||
func Init(flagConfigFile string) {
|
func Init(flagConfigFile string) {
|
||||||
f, err := os.Open(flagConfigFile)
|
f, err := os.Open(flagConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) || flagConfigFile != "./config.json" {
|
if !os.IsNotExist(err) {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -123,5 +123,9 @@ func Init(flagConfigFile string) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
|
if Keys.Clusters == nil || len(Keys.Clusters) < 1 {
|
||||||
|
log.Fatal("At least one cluster required in config!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type FsArchiveConfig struct {
|
type FsArchiveConfig struct {
|
||||||
Path string `json:"filePath"`
|
Path string `json:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FsArchive struct {
|
type FsArchive struct {
|
||||||
|
@ -28,11 +28,17 @@ import (
|
|||||||
|
|
||||||
func setup(t *testing.T) *api.RestApi {
|
func setup(t *testing.T) *api.RestApi {
|
||||||
const testconfig = `{
|
const testconfig = `{
|
||||||
"addr": "0.0.0.0:80",
|
"addr": "0.0.0.0:8080",
|
||||||
"archive": {
|
"archive": {
|
||||||
"kind": "file",
|
"kind": "file",
|
||||||
"path": "./var/job-archive"
|
"path": "./var/job-archive"
|
||||||
|
},
|
||||||
|
"clusters": [
|
||||||
|
{
|
||||||
|
"name": "testcluster",
|
||||||
|
"metricDataRepository": {"kind": "test"}
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}`
|
}`
|
||||||
const testclusterJson = `{
|
const testclusterJson = `{
|
||||||
"name": "testcluster",
|
"name": "testcluster",
|
||||||
@ -109,12 +115,11 @@ func setup(t *testing.T) *api.RestApi {
|
|||||||
|
|
||||||
config.Init(cfgFilePath)
|
config.Init(cfgFilePath)
|
||||||
archiveCfg := fmt.Sprintf("{\"kind\":\"file\",\"path\":\"%s\"}", jobarchive)
|
archiveCfg := fmt.Sprintf("{\"kind\":\"file\",\"path\":\"%s\"}", jobarchive)
|
||||||
config.Keys.Archive = []byte(archiveCfg)
|
|
||||||
|
|
||||||
repository.Connect("sqlite3", dbfilepath)
|
repository.Connect("sqlite3", dbfilepath)
|
||||||
db := repository.GetConnection()
|
db := repository.GetConnection()
|
||||||
|
|
||||||
if err := archive.Init(config.Keys.Archive); err != nil {
|
if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user