Allow running CLI-related integration tests with pre-built binary.
This allows setting `$PINNIPED_TEST_CLI` to point at an existing `pinniped` CLI binary instead of having the test build one on-the-fly. This is more efficient when you're running the tests across many clusters as we do in CI. Building the CLI from scratch in our CI environment takes 1.5-2 minutes, so this change should save nearly that much time on every test job. Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
e70788204b
commit
cda8bd6e26
@ -1,10 +1,11 @@
|
|||||||
// Copyright 2020 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package library
|
package library
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
@ -24,6 +25,13 @@ var pinnipedCLIBinaryCache struct {
|
|||||||
// PinnipedCLIPath returns the path to the Pinniped CLI binary, built on demand and cached between tests.
|
// PinnipedCLIPath returns the path to the Pinniped CLI binary, built on demand and cached between tests.
|
||||||
func PinnipedCLIPath(t *testing.T) string {
|
func PinnipedCLIPath(t *testing.T) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
// Allow a pre-built binary passed in via $PINNIPED_TEST_CLI. This is how our tests run in CI for efficiency.
|
||||||
|
if ext, ok := os.LookupEnv("PINNIPED_TEST_CLI"); ok {
|
||||||
|
t.Log("using externally provided pinniped CLI binary")
|
||||||
|
return ext
|
||||||
|
}
|
||||||
|
|
||||||
pinnipedCLIBinaryCache.mutex.Lock()
|
pinnipedCLIBinaryCache.mutex.Lock()
|
||||||
defer pinnipedCLIBinaryCache.mutex.Unlock()
|
defer pinnipedCLIBinaryCache.mutex.Unlock()
|
||||||
path := filepath.Join(testutil.TempDir(t), "pinniped")
|
path := filepath.Join(testutil.TempDir(t), "pinniped")
|
||||||
|
Loading…
Reference in New Issue
Block a user