-
Notifications
You must be signed in to change notification settings - Fork 126
/
docker_integration_test.go
71 lines (65 loc) · 1.6 KB
/
docker_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cloud
import (
"context"
"os"
"testing"
"time"
"github.com/docker/docker/api/types"
"github.com/evergreen-ci/evergreen"
"github.com/evergreen-ci/evergreen/model/host"
"github.com/evergreen-ci/evergreen/testutil"
"github.com/evergreen-ci/utility"
"github.com/mongodb/grip"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type DockerIntegrationSuite struct {
host host.Host
settings *evergreen.Settings
client dockerClientImpl
suite.Suite
}
func TestDockerIntegrationSuite(t *testing.T) {
dns := os.Getenv("DOCKER_HOST")
if dns == "" {
t.Skip()
}
settings := testutil.TestConfig()
testutil.ConfigureIntegrationTest(t, settings)
s := &DockerIntegrationSuite{
host: host.Host{
Host: dns,
ContainerPoolSettings: &evergreen.ContainerPool{
Port: 2376,
},
},
settings: settings,
client: dockerClientImpl{
evergreenSettings: settings,
},
}
assert.NoError(t, s.client.Init("1.37"))
suite.Run(t, s)
}
func (s *DockerIntegrationSuite) TestImagePull() {
const imageName = "public.ecr.aws/docker/library/hello-world:latest"
var err error
ctx := context.Background()
err = utility.Retry(ctx, func() (bool, error) {
err = s.client.pullImage(ctx, &s.host, imageName, "", "")
if err != nil {
return true, err
}
return false, nil
}, utility.RetryOptions{
MaxAttempts: 10,
MinDelay: time.Second,
MaxDelay: 10 * time.Minute,
})
s.NoError(err)
images, err := s.client.client.ImageList(ctx, types.ImageListOptions{All: true})
s.NoError(err)
s.Require().Len(images, 1)
grip.Info(images)
s.Contains(images[0].RepoTags, imageName)
}