2f0cfb5740
This PR upgrades our CI images and fixes some affected tests. - upgrade go-machine-image to premade latest ubuntu LTS (ubuntu-2004:202111-02) - eliminate go-machine-recent-image (no longer necessary) - manage GOPATH in GNUMakefile (see https://discuss.circleci.com/t/gopath-is-set-to-multiple-directories/7174) - fix tcp dial error check (message seems to be OS specific) - spot check values measured instead of specifically 'RSS' (rss no longer reported in cgroups v2) - use safe MkdirTemp for generating tmpfiles NOT applied: (too flakey) - eliminate setting GOMAXPROCS=1 (build tools were also affected by this setting) - upgrade resource type for all imanges to large (2C -> 4C)
49 lines
851 B
Go
49 lines
851 B
Go
package testutil
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestWait_WaitForFilesUntil(t *testing.T) {
|
|
|
|
N := 10
|
|
|
|
tmpDir, err := os.MkdirTemp("", "waiter")
|
|
require.NoError(t, err)
|
|
|
|
defer func() {
|
|
require.NoError(t, os.RemoveAll(tmpDir))
|
|
}()
|
|
|
|
var files []string
|
|
for i := 1; i < N; i++ {
|
|
files = append(files, filepath.Join(
|
|
tmpDir, fmt.Sprintf("test%d.txt", i),
|
|
))
|
|
}
|
|
|
|
go func() {
|
|
for _, file := range files {
|
|
t.Logf("Creating file %s ...", file)
|
|
fh, createErr := os.Create(file)
|
|
require.NoError(t, createErr)
|
|
|
|
closeErr := fh.Close()
|
|
require.NoError(t, closeErr)
|
|
require.FileExists(t, file)
|
|
|
|
time.Sleep(250 * time.Millisecond)
|
|
}
|
|
}()
|
|
|
|
duration := 5 * time.Second
|
|
t.Log("Waiting 5 seconds for files ...")
|
|
WaitForFilesUntil(t, files, duration)
|
|
}
|