github.com/hernad/nomad@v1.6.112/ci/slow.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package ci
     5  
     6  import (
     7  	"os"
     8  	"strconv"
     9  	"testing"
    10  )
    11  
    12  // SkipSlow skips a slow test unless NOMAD_SLOW_TEST is set to a true value.
    13  func SkipSlow(t *testing.T, reason string) {
    14  	value := os.Getenv("NOMAD_SLOW_TEST")
    15  	run, err := strconv.ParseBool(value)
    16  	if !run || err != nil {
    17  		t.Skipf("Skipping slow test: %s", reason)
    18  	}
    19  }
    20  
    21  // Parallel runs t in parallel, unless CI is set to a true value.
    22  //
    23  // In CI (CircleCI / GitHub Actions) we get better performance by running tests
    24  // in serial while not restricting GOMAXPROCS.
    25  func Parallel(t *testing.T) {
    26  	value := os.Getenv("CI")
    27  	isCI, err := strconv.ParseBool(value)
    28  	if !isCI || err != nil {
    29  		t.Parallel()
    30  	}
    31  }
    32  
    33  // TinyChroot is useful for testing, where we do not use anything other than
    34  // trivial /bin commands like sleep and sh. Copying a minimal chroot helps in
    35  // environments like GHA with very poor [network] disk performance.
    36  //
    37  // Note that you cannot chroot a symlink.
    38  //
    39  // Do not modify this value.
    40  var TinyChroot = map[string]string{
    41  	// destination: /bin
    42  	"/usr/bin/sleep": "/bin/sleep",
    43  	"/usr/bin/dash":  "/bin/sh",
    44  	"/usr/bin/bash":  "/bin/bash",
    45  	"/usr/bin/cat":   "/bin/cat",
    46  
    47  	// destination: /usr/bin
    48  	"/usr/bin/stty":   "/usr/bin/stty",
    49  	"/usr/bin/head":   "/usr/bin/head",
    50  	"/usr/bin/mktemp": "/usr/bin/mktemp",
    51  	"/usr/bin/echo":   "/usr/bin/echo",
    52  	"/usr/bin/touch":  "/usr/bin/touch",
    53  	"/usr/bin/stat":   "/usr/bin/stat",
    54  
    55  	// destination: /etc/
    56  	"/etc/ld.so.cache":  "/etc/ld.so.cache",
    57  	"/etc/ld.so.conf":   "/etc/ld.so.conf",
    58  	"/etc/ld.so.conf.d": "/etc/ld.so.conf.d",
    59  	"/etc/passwd":       "/etc/passwd",
    60  	"/etc/resolv.conf":  "/etc/resolv.conf",
    61  
    62  	// others
    63  	"/lib":                 "/lib",
    64  	"/lib32":               "/lib32",
    65  	"/lib64":               "/lib64",
    66  	"/usr/lib/jvm":         "/usr/lib/jvm",
    67  	"/run/resolvconf":      "/run/resolvconf",
    68  	"/run/systemd/resolve": "/run/systemd/resolve",
    69  }