open-nomad/api/util_test.go
Alex Dadgar 1e3c3cb287 Deprecate IOPS
IOPS have been modelled as a resource since Nomad 0.1 but has never
actually been detected and there is no plan in the short term to add
detection. This is because IOPS is a bit simplistic of a unit to define
the performance requirements from the underlying storage system. In its
current state it adds unnecessary confusion and can be removed without
impacting any users. This PR leaves IOPS defined at the jobspec parsing
level and in the api/ resources since these are the two public uses of
the field. These should be considered deprecated and only exist to allow
users to stop using them during the Nomad 0.9.x release. In the future,
there should be no expectation that the field will exist.
2018-12-06 15:09:26 -08:00

82 lines
1.6 KiB
Go

package api
import (
"testing"
"github.com/hashicorp/nomad/helper"
)
func assertQueryMeta(t *testing.T, qm *QueryMeta) {
t.Helper()
if qm.LastIndex == 0 {
t.Fatalf("bad index: %d", qm.LastIndex)
}
if !qm.KnownLeader {
t.Fatalf("expected known leader, got none")
}
}
func assertWriteMeta(t *testing.T, wm *WriteMeta) {
t.Helper()
if wm.LastIndex == 0 {
t.Fatalf("bad index: %d", wm.LastIndex)
}
}
func testJob() *Job {
task := NewTask("task1", "exec").
SetConfig("command", "/bin/sleep").
Require(&Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(256),
}).
SetLogConfig(&LogConfig{
MaxFiles: helper.IntToPtr(1),
MaxFileSizeMB: helper.IntToPtr(2),
})
group := NewTaskGroup("group1", 1).
AddTask(task).
RequireDisk(&EphemeralDisk{
SizeMB: helper.IntToPtr(25),
})
job := NewBatchJob("job1", "redis", "region1", 1).
AddDatacenter("dc1").
AddTaskGroup(group)
return job
}
func testPeriodicJob() *Job {
job := testJob().AddPeriodicConfig(&PeriodicConfig{
Enabled: helper.BoolToPtr(true),
Spec: helper.StringToPtr("*/30 * * * *"),
SpecType: helper.StringToPtr("cron"),
})
return job
}
func testNamespace() *Namespace {
return &Namespace{
Name: "test-namespace",
Description: "Testing namespaces",
}
}
func testQuotaSpec() *QuotaSpec {
return &QuotaSpec{
Name: "test-namespace",
Description: "Testing namespaces",
Limits: []*QuotaLimit{
{
Region: "global",
RegionLimit: &Resources{
CPU: helper.IntToPtr(2000),
MemoryMB: helper.IntToPtr(2000),
},
},
},
}
}