github.com/hernad/nomad@v1.6.112/e2e/v3/util3/util3.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package util3
     5  
     6  import (
     7  	"fmt"
     8  	"math/rand"
     9  	"os"
    10  	"testing"
    11  )
    12  
    13  func ShortID(prefix string) string {
    14  	num := rand.Int31() % 1000
    15  	return fmt.Sprintf("%s-%03d", prefix, num)
    16  }
    17  
    18  // Log3 is a helper for verbose logging in e2e/v3 packages.
    19  //
    20  // Do not call this directly from tests.
    21  func Log3(t *testing.T, verbose bool, msg string, args ...any) {
    22  	env := os.Getenv("NOMAD_E2E_VERBOSE")
    23  	on := verbose || env == "1" || env == "true"
    24  	if on {
    25  		t.Logf(msg, args...)
    26  	}
    27  }