2588b3bc98
This fixes few cases where driver eventor goroutines are leaked during normal operations, but especially so in tests. This change makes few modifications: First, it switches drivers to use `Context`s to manage shutdown events. Previously, it relied on callers invoking `.Shutdown()` function that is specific to internal drivers only and require casting. Using `Contexts` provide a consistent idiomatic way to manage lifecycle for both internal and external drivers. Also, I discovered few places where we don't clean up a temporary driver instance in the plugin catalog code, where we dispense a driver to inspect and validate the schema config without properly cleaning it up.
32 lines
792 B
Go
32 lines
792 B
Go
package docker
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/client/testutil"
|
|
"github.com/hashicorp/nomad/helper/testlog"
|
|
"github.com/hashicorp/nomad/plugins/drivers"
|
|
tu "github.com/hashicorp/nomad/testutil"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestDockerDriver_FingerprintHealth asserts that docker reports healthy
|
|
// whenever Docker is supported.
|
|
//
|
|
// In Linux CI and AppVeyor Windows environment, it should be enabled.
|
|
func TestDockerDriver_FingerprintHealth(t *testing.T) {
|
|
if !tu.IsCI() {
|
|
t.Parallel()
|
|
}
|
|
testutil.DockerCompatible(t)
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
d := NewDockerDriver(ctx, testlog.HCLogger(t)).(*Driver)
|
|
|
|
fp := d.buildFingerprint()
|
|
require.Equal(t, drivers.HealthStateHealthy, fp.Health)
|
|
}
|