Use nifty testtask sleep command for xplat compat
This commit is contained in:
parent
caf317e3f2
commit
5e908dbf38
|
@ -145,7 +145,7 @@ func TestConsul_Integration(t *testing.T) {
|
|||
// Block waiting for the service to appear
|
||||
catalog := consulClient.Catalog()
|
||||
res, meta, err := catalog.Service("httpd2", "test", nil)
|
||||
for len(res) == 0 {
|
||||
for i := 0; len(res) == 0 && i < 10; i++ {
|
||||
//Expected initial request to fail, do a blocking query
|
||||
res, meta, err = catalog.Service("httpd2", "test", &consulapi.QueryOptions{WaitIndex: meta.LastIndex + 1, WaitTime: 3 * time.Second})
|
||||
if err != nil {
|
||||
|
@ -158,7 +158,7 @@ func TestConsul_Integration(t *testing.T) {
|
|||
res = res[:]
|
||||
|
||||
// Assert the service with the checks exists
|
||||
for len(res) == 0 {
|
||||
for i := 0; len(res) == 0 && i < 10; i++ {
|
||||
res, meta, err = catalog.Service("httpd", "http", &consulapi.QueryOptions{WaitIndex: meta.LastIndex + 1, WaitTime: 3 * time.Second})
|
||||
if err != nil {
|
||||
t.Fatalf("error querying for service: %v", err)
|
||||
|
|
|
@ -2,14 +2,22 @@ package consul
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/nomad/helper/testtask"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
if !testtask.Run() {
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
}
|
||||
|
||||
// blockingScriptExec implements ScriptExec by running a subcommand that never
|
||||
// exits.
|
||||
type blockingScriptExec struct {
|
||||
|
@ -26,7 +34,7 @@ func newBlockingScriptExec() *blockingScriptExec {
|
|||
|
||||
func (b *blockingScriptExec) Exec(ctx context.Context, _ string, _ []string) ([]byte, int, error) {
|
||||
b.running <- mark
|
||||
cmd := exec.CommandContext(ctx, "/bin/sleep", "9000")
|
||||
cmd := exec.CommandContext(ctx, testtask.Path(), "sleep", "9000h")
|
||||
err := cmd.Run()
|
||||
code := 0
|
||||
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||
|
|
Loading…
Reference in New Issue