Merge pull request #8992 from hashicorp/b-tests-failover-copy
tests: failover to copying when symlinking fails
This commit is contained in:
commit
eb5ff115a5
|
@ -332,9 +332,6 @@ func copyFile(src, dst string, t *testing.T) {
|
|||
if _, err = io.Copy(out, in); err != nil {
|
||||
t.Fatalf("copying %v -> %v failed: %v", src, dst, err)
|
||||
}
|
||||
if err := out.Sync(); err != nil {
|
||||
t.Fatalf("copying %v -> %v failed: %v", src, dst, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfig_ParseAllHCL(t *testing.T) {
|
||||
|
|
|
@ -482,7 +482,29 @@ func setupRootfsBinary(t *testing.T, rootfs, path string) {
|
|||
)
|
||||
|
||||
err = os.Link(src, dst)
|
||||
require.NoError(t, err)
|
||||
if err != nil {
|
||||
// On failure, fallback to copying the file directly.
|
||||
// Linking may fail if the test source code lives on a separate
|
||||
// volume/partition from the temp dir used for testing
|
||||
copyFile(t, src, dst)
|
||||
}
|
||||
}
|
||||
|
||||
func copyFile(t *testing.T, src, dst string) {
|
||||
in, err := os.Open(src)
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dst)
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
defer func() {
|
||||
if err := out.Close(); err != nil {
|
||||
t.Fatalf("copying %v -> %v failed: %v", src, dst, err)
|
||||
}
|
||||
}()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
require.NoErrorf(t, err, "copying %v -> %v", src, dst)
|
||||
}
|
||||
|
||||
// TestExecutor_Start_Kill_Immediately_NoGrace asserts that executors shutdown
|
||||
|
|
Loading…
Reference in a new issue