Skip to content

Commit 342a9de

Browse files
committed
Merge branch 'main' into provisionerservice
2 parents ab7fbec + 9db5fb0 commit 342a9de

File tree

15 files changed

+342
-227
lines changed

15 files changed

+342
-227
lines changed

.github/workflows/coder.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,17 @@ jobs:
148148
149149
- run: go install gotest.tools/gotestsum@latest
150150

151+
- uses: hashicorp/setup-terraform@v1
152+
if: runner.os == 'Linux'
153+
with:
154+
terraform_version: 1.1.2
155+
terraform_wrapper: false
156+
151157
- name: Test with Mock Database
152158
run:
153159
gotestsum --jsonfile="gotests.json" --packages="./..." --
154160
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
155-
-count=3 -race -parallel=2
161+
-count=3 -race -short -parallel=2
156162

157163
- name: Test with PostgreSQL Database
158164
if: runner.os == 'Linux'

coderd/userpassword/userpassword_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This test runs slowly on MacOS instance, and really
2+
// only needs to run on Linux anyways.
3+
//go:build linux
4+
15
package userpassword_test
26

37
import (

database/migrate_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ func TestMain(m *testing.M) {
2020
func TestMigrate(t *testing.T) {
2121
t.Parallel()
2222

23+
if testing.Short() {
24+
t.Skip()
25+
return
26+
}
27+
2328
t.Run("Once", func(t *testing.T) {
2429
t.Parallel()
2530
connection, closeFn, err := postgres.Open()

database/postgres/postgres.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package postgres
33
import (
44
"database/sql"
55
"fmt"
6+
"io/ioutil"
7+
"os"
68
"time"
79

810
"github.com/ory/dockertest/v3"
@@ -16,15 +18,29 @@ func Open() (string, func(), error) {
1618
if err != nil {
1719
return "", nil, xerrors.Errorf("create pool: %w", err)
1820
}
21+
tempDir, err := ioutil.TempDir(os.TempDir(), "postgres")
22+
if err != nil {
23+
return "", nil, xerrors.Errorf("create tempdir: %w", err)
24+
}
1925
resource, err := pool.RunWithOptions(&dockertest.RunOptions{
2026
Repository: "postgres",
2127
Tag: "11",
2228
Env: []string{
2329
"POSTGRES_PASSWORD=postgres",
2430
"POSTGRES_USER=postgres",
2531
"POSTGRES_DB=postgres",
32+
// The location for temporary database files!
33+
"PGDATA=/tmp",
2634
"listen_addresses = '*'",
2735
},
36+
Mounts: []string{
37+
// The postgres image has a VOLUME parameter in it's image.
38+
// If we don't mount at this point, Docker will allocate a
39+
// volume for this directory.
40+
//
41+
// This isn't used anyways, since we override PGDATA.
42+
fmt.Sprintf("%s:/var/lib/postgresql/data", tempDir),
43+
},
2844
}, func(config *docker.HostConfig) {
2945
// set AutoRemove to true so that stopped container goes away by itself
3046
config.AutoRemove = true
@@ -57,5 +73,6 @@ func Open() (string, func(), error) {
5773
}
5874
return dbURL, func() {
5975
_ = pool.Purge(resource)
76+
_ = os.RemoveAll(tempDir)
6077
}, nil
6178
}

database/postgres/postgres_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func TestMain(m *testing.M) {
2121
func TestPostgres(t *testing.T) {
2222
t.Parallel()
2323

24+
if testing.Short() {
25+
t.Skip()
26+
return
27+
}
28+
2429
connect, close, err := postgres.Open()
2530
require.NoError(t, err)
2631
defer close()

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ require (
1717
github.com/golang-migrate/migrate/v4 v4.15.1
1818
github.com/google/uuid v1.3.0
1919
github.com/hashicorp/go-version v1.4.0
20-
github.com/hashicorp/hc-install v0.3.1
2120
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
2221
github.com/hashicorp/terraform-exec v0.15.0
2322
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87
@@ -68,7 +67,6 @@ require (
6867
github.com/google/go-cmp v0.5.7 // indirect
6968
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
7069
github.com/hashicorp/errwrap v1.1.0 // indirect
71-
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
7270
github.com/hashicorp/go-multierror v1.1.1 // indirect
7371
github.com/hashicorp/hcl v1.0.0 // indirect
7472
github.com/hashicorp/hcl/v2 v2.11.1 // indirect

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,6 @@ github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
688688
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
689689
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
690690
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
691-
github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk=
692-
github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
693691
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
694692
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
695693
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
@@ -1303,7 +1301,6 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
13031301
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
13041302
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
13051303
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
1306-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13071304
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13081305
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
13091306
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

peer/channel.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
// The initialization overrides listener handles, and detaches
2828
// the channel on open. The datachannel should not be manually
2929
// mutated after being passed to this function.
30-
func newChannel(conn *Conn, dc *webrtc.DataChannel, opts *ChannelOpts) *Channel {
30+
func newChannel(conn *Conn, dc *webrtc.DataChannel, opts *ChannelOptions) *Channel {
3131
channel := &Channel{
3232
opts: opts,
3333
conn: conn,
@@ -41,7 +41,7 @@ func newChannel(conn *Conn, dc *webrtc.DataChannel, opts *ChannelOpts) *Channel
4141
return channel
4242
}
4343

44-
type ChannelOpts struct {
44+
type ChannelOptions struct {
4545
// ID is a channel ID that should be used when `Negotiated`
4646
// is true.
4747
ID uint16
@@ -72,7 +72,7 @@ type ChannelOpts struct {
7272
// WebRTC PeerConnection failure. This is done to emulate TCP connections.
7373
// This option can be changed in the options when creating a Channel.
7474
type Channel struct {
75-
opts *ChannelOpts
75+
opts *ChannelOptions
7676

7777
conn *Conn
7878
dc *webrtc.DataChannel
@@ -141,9 +141,9 @@ func (c *Channel) init() {
141141
// A DataChannel can disconnect multiple times, so this needs to loop.
142142
for {
143143
select {
144-
case <-c.closed:
144+
case <-c.conn.closedRTC:
145145
// If this channel was closed, there's no need to close again.
146-
return
146+
err = c.conn.closeError
147147
case <-c.conn.Closed():
148148
// If the RTC connection closed with an error, this channel
149149
// should end with the same one.

0 commit comments

Comments
 (0)