From 1d7de76e49ce7db549a265acd1eb39bed2876351 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 20 May 2022 22:00:25 +0100 Subject: [PATCH 1/3] chore: skip some flaky tests --- cli/parameter.go | 3 ++- cli/ssh_test.go | 1 + coderd/workspaces_test.go | 3 ++- peer/conn_test.go | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/parameter.go b/cli/parameter.go index 5efb81f9fd405..904148ae13005 100644 --- a/cli/parameter.go +++ b/cli/parameter.go @@ -6,9 +6,10 @@ import ( "golang.org/x/xerrors" "gopkg.in/yaml.v3" + "github.com/spf13/cobra" + "github.com/coder/coder/cli/cliui" "github.com/coder/coder/codersdk" - "github.com/spf13/cobra" ) // Reads a YAML file and populates a string -> string map. diff --git a/cli/ssh_test.go b/cli/ssh_test.go index ac638e7cef45a..5677678d4986c 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -23,6 +23,7 @@ import ( ) func TestSSH(t *testing.T) { + t.Skip("This is causing test flakes. TODO @cian fix this") t.Parallel() t.Run("ImmediateExit", func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index cd44a1895d450..62acc4d5528c0 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -182,7 +182,8 @@ func TestWorkspacesByOrganization(t *testing.T) { version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) coderdtest.AwaitTemplateVersionJob(t, client, version.ID) template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - _ = coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) + ws := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) + _ = coderdtest.AwaitWorkspaceBuildJob(t, client, ws.LatestBuild.ID) workspaces, err := client.WorkspacesByOrganization(context.Background(), user.OrganizationID) require.NoError(t, err) require.Len(t, workspaces, 1) diff --git a/peer/conn_test.go b/peer/conn_test.go index 46bcea980e5f3..4ec4c51d78092 100644 --- a/peer/conn_test.go +++ b/peer/conn_test.go @@ -59,6 +59,7 @@ func TestMain(m *testing.M) { } func TestConn(t *testing.T) { + t.Skip("peer tests are known to be flaky") t.Parallel() t.Run("Ping", func(t *testing.T) { From e915c213d422626008583d81dd37bdd88cfda1c4 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Fri, 20 May 2022 22:13:50 +0100 Subject: [PATCH 2/3] Update peer/conn_test.go --- peer/conn_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peer/conn_test.go b/peer/conn_test.go index 4ec4c51d78092..2da03bd3ade09 100644 --- a/peer/conn_test.go +++ b/peer/conn_test.go @@ -59,7 +59,7 @@ func TestMain(m *testing.M) { } func TestConn(t *testing.T) { - t.Skip("peer tests are known to be flaky") + t.Skip("known flake -- https://github.com/coder/coder/issues/1644") t.Parallel() t.Run("Ping", func(t *testing.T) { From 399cb3fb596dd268eb70b26b3661c1ab21892db7 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Sat, 21 May 2022 00:17:22 +0100 Subject: [PATCH 3/3] add makefile targets, reduce parallelism in go test --- .github/workflows/coder.yaml | 5 +---- Makefile | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 1b05e7539c6c2..6ded192d465ab 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -275,10 +275,7 @@ jobs: done - name: Test with PostgreSQL Database - run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- - -covermode=atomic -coverprofile="gotests.coverage" -timeout=3m - -coverpkg=./...,github.com/coder/coder/codersdk - -count=1 -parallel=2 -race -failfast + run: "make test-postgres" - name: Upload DataDog Trace if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork diff --git a/Makefile b/Makefile index b3d38a5e0e02d..fa1ea76cafe1a 100644 --- a/Makefile +++ b/Makefile @@ -91,5 +91,33 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts cd site && yarn run format:types -test: +.PHONY: test +test: test-clean gotestsum -- -v -short ./... + +.PHONY: test-postgres +test-postgres: test-clean + DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \ + -covermode=atomic -coverprofile="gotests.coverage" -timeout=5m \ + -coverpkg=./...,github.com/coder/coder/codersdk \ + -count=1 -parallel=1 -race -failfast + + +.PHONY: test-postgres-docker +test-postgres-docker: + docker run \ + --env POSTGRES_PASSWORD=postgres \ + --env POSTGRES_USER=postgres \ + --env POSTGRES_DB=postgres \ + --env PGDATA=/tmp \ + --publish 5432:5432 \ + --name test-postgres-docker \ + --restart unless-stopped \ + --detach \ + postgres:11 \ + -c shared_buffers=1GB \ + -c max_connections=1000 + +.PHONY: test-clean +test-clean: + go clean -testcache