Skip to content

Commit

Permalink
Merge branch 'master' into b-vault-race
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar authored Feb 2, 2017
2 parents 9e822a2 + efc0602 commit 4bf2401
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
32 changes: 23 additions & 9 deletions client/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import (
"log"
"os"
"testing"
"time"

"github.com/hashicorp/nomad/client/stats"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
)

var gcConfig = GCConfig{
DiskUsageThreshold: 80,
InodeUsageThreshold: 70,
Interval: 1 * time.Minute,
ReservedDiskMB: 0,
}

func TestIndexedGCAllocPQ(t *testing.T) {
pq := NewIndexedGCAllocPQ()

Expand Down Expand Up @@ -83,7 +91,7 @@ func (m *MockStatsCollector) Stats() *stats.HostStats {

func TestAllocGarbageCollector_MarkForCollection(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
if err := gc.MarkForCollection(ar1); err != nil {
Expand All @@ -98,7 +106,7 @@ func TestAllocGarbageCollector_MarkForCollection(t *testing.T) {

func TestAllocGarbageCollector_Collect(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
_, ar2 := testAllocRunnerFromAlloc(mock.Alloc(), false)
Expand All @@ -120,7 +128,7 @@ func TestAllocGarbageCollector_Collect(t *testing.T) {

func TestAllocGarbageCollector_CollectAll(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, 0)
gc := NewAllocGarbageCollector(logger, &MockStatsCollector{}, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
_, ar2 := testAllocRunnerFromAlloc(mock.Alloc(), false)
Expand All @@ -143,7 +151,8 @@ func TestAllocGarbageCollector_CollectAll(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_EnoughSpace(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -179,7 +188,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_EnoughSpace(t *testing.T)
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Partial(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -216,7 +226,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Partial(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_All(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -249,7 +260,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_All(t *testing.T) {
func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Fallback(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -281,7 +293,8 @@ func TestAllocGarbageCollector_MakeRoomForAllocations_GC_Fallback(t *testing.T)
func TestAllocGarbageCollector_UsageBelowThreshold(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down Expand Up @@ -314,7 +327,8 @@ func TestAllocGarbageCollector_UsageBelowThreshold(t *testing.T) {
func TestAllocGarbageCollector_UsedPercentThreshold(t *testing.T) {
logger := log.New(os.Stdout, "", 0)
statsCollector := &MockStatsCollector{}
gc := NewAllocGarbageCollector(logger, statsCollector, 20)
gcConfig.ReservedDiskMB = 20
gc := NewAllocGarbageCollector(logger, statsCollector, &gcConfig)

_, ar1 := testAllocRunnerFromAlloc(mock.Alloc(), false)
close(ar1.waitCh)
Expand Down
3 changes: 3 additions & 0 deletions nomad/structs/config/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func TestVaultConfig_Merge(t *testing.T) {
c1 := &VaultConfig{
Enabled: &falseValue,
Token: "1",
Role: "1",
AllowUnauthenticated: &trueValue,
TaskTokenTTL: "1",
Addr: "1",
Expand All @@ -24,6 +25,7 @@ func TestVaultConfig_Merge(t *testing.T) {
c2 := &VaultConfig{
Enabled: &trueValue,
Token: "2",
Role: "2",
AllowUnauthenticated: &falseValue,
TaskTokenTTL: "2",
Addr: "2",
Expand All @@ -38,6 +40,7 @@ func TestVaultConfig_Merge(t *testing.T) {
e := &VaultConfig{
Enabled: &trueValue,
Token: "2",
Role: "2",
AllowUnauthenticated: &falseValue,
TaskTokenTTL: "2",
Addr: "2",
Expand Down
12 changes: 7 additions & 5 deletions website/source/docs/drivers/rkt.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,18 @@ The `rkt` driver supports the following configuration in the job spec:
* `net` - (Optional) A list of networks to be used by the containers
* `port_map` - (Optional) A key/value map of port to be used by the container.
port name in the image manifest file needs to be specified for the value. For example:
* `port_map` - (Optional) A key/value map of ports used by the container. The
value is the port name specified in the image manifest file. When running
Docker images with rkt the port names will be of the form `${PORT}-tcp`. See
[networking](#networking) below for more details.
```
```hcl
port_map {
# If running a Docker image that exposes port 8080
app = "8080-tcp"
}
```
See below for more details.


* `debug` - (Optional) Enable rkt command debug option.

Expand Down

0 comments on commit 4bf2401

Please sign in to comment.