Files
nomad/e2e/v3/util3/util3.go
Daniel Bennett f7adcefbb3 e2e: refactor vault secrets test (#19152)
fixes VaultSecrets test - it was failing due to a
regex mismatch (`^job` stopped matching when
copywrite headers got prepended to the jobspec).

but RegisterFromJobspec (which had the bug)
was only used in the one spot, so instead this
refactors the whole test to the v3 format
with testing.T and some additional fun stuff
that we can take advantage of with it.

some improvements:
* use a namespace
* use and extend existing test helpers
* add more test helpers
2023-11-28 10:00:27 -06:00

29 lines
550 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package util3
import (
"fmt"
"math/rand"
"os"
"testing"
)
func ShortID(prefix string) string {
num := rand.Int31() % 1000
return fmt.Sprintf("%s-%03d", prefix, num)
}
// Log3 is a helper for verbose logging in e2e/v3 packages.
//
// Do not call this directly from tests.
func Log3(t *testing.T, verbose bool, msg string, args ...any) {
t.Helper()
env := os.Getenv("NOMAD_E2E_VERBOSE")
on := verbose || env == "1" || env == "true"
if on {
t.Logf(msg, args...)
}
}