Skip to content

Commit 5eedfbe

Browse files
committed
Merge branch 'main' into bryphe/feat/initial-e2e-tests
2 parents d7f9257 + 7e72eb9 commit 5eedfbe

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

database/postgres/postgres.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ import (
66
"io/ioutil"
77
"net"
88
"os"
9+
"sync"
910
"time"
1011

1112
"github.com/ory/dockertest/v3"
1213
"github.com/ory/dockertest/v3/docker"
1314
"golang.org/x/xerrors"
1415
)
1516

17+
// Required to prevent port collision during container creation.
18+
// Super unlikely, but it happened. See: https://github.com/coder/coder/runs/5375197003
19+
var openPortMutex sync.Mutex
20+
1621
// Open creates a new PostgreSQL server using a Docker container.
1722
func Open() (string, func(), error) {
1823
pool, err := dockertest.NewPool("")
@@ -23,10 +28,12 @@ func Open() (string, func(), error) {
2328
if err != nil {
2429
return "", nil, xerrors.Errorf("create tempdir: %w", err)
2530
}
31+
openPortMutex.Lock()
2632
// Pick an explicit port on the host to connect to 5432.
2733
// This is necessary so we can configure the port to only use ipv4.
2834
port, err := getFreePort()
2935
if err != nil {
36+
openPortMutex.Unlock()
3037
return "", nil, xerrors.Errorf("Unable to get free port: %w", err)
3138
}
3239

@@ -64,8 +71,11 @@ func Open() (string, func(), error) {
6471
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
6572
})
6673
if err != nil {
74+
openPortMutex.Unlock()
6775
return "", nil, xerrors.Errorf("could not start resource: %w", err)
6876
}
77+
openPortMutex.Unlock()
78+
6979
hostAndPort := resource.GetHostPort("5432/tcp")
7080
dbURL := fmt.Sprintf("postgres://postgres:postgres@%s/postgres?sslmode=disable", hostAndPort)
7181

provisionerd/provisionerd_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,15 +466,13 @@ func TestProvisionerd(t *testing.T) {
466466
})
467467
require.NoError(t, err)
468468
<-shutdownCtx.Done()
469-
err = stream.Send(&sdkproto.Provision_Response{
469+
return stream.Send(&sdkproto.Provision_Response{
470470
Type: &sdkproto.Provision_Response_Complete{
471471
Complete: &sdkproto.Provision_Complete{
472472
Error: "some error",
473473
},
474474
},
475475
})
476-
require.NoError(t, err)
477-
return nil
478476
},
479477
}),
480478
})

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"ts-jest": "27.1.3",
6767
"ts-loader": "9.2.6",
6868
"ts-node": "10.5.0",
69-
"typescript": "4.5.5",
69+
"typescript": "4.6.2",
7070
"yup": "0.32.11"
7171
},
7272
"dependencies": {},

site/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12097,10 +12097,10 @@ typedarray@^0.0.6:
1209712097
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1209812098
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1209912099

12100-
typescript@4.5.5:
12101-
version "4.5.5"
12102-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
12103-
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==
12100+
typescript@4.6.2:
12101+
version "4.6.2"
12102+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
12103+
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
1210412104

1210512105
ua-parser-js@^0.7.30:
1210612106
version "0.7.31"

0 commit comments

Comments
 (0)