Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Run tests using PostgreSQL database and mock #49

Merged
merged 6 commits into from
Jan 22, 2022
Merged

ci: Run tests using PostgreSQL database and mock #49

merged 6 commits into from
Jan 22, 2022

Conversation

kylecarbs
Copy link
Member

@kylecarbs kylecarbs commented Jan 22, 2022

This allows us to use the mock database for quick iterative testing,
and have confidence from CI using a real PostgreSQL database.

PostgreSQL tests are only ran on Linux. They are really slow on MacOS
and Windows runners, and don't provide much additional confidence.

This also allows DB=true go test ... locally to leverage our Docker PostgreSQL
code for running tests!

This allows us to use the mock database for quick iterative testing,
and have confidence from CI using a real PostgreSQL database.

PostgreSQL tests are only ran on Linux. They are *really* slow on MacOS
and Windows runners, and don't provide much additional confidence.
@kylecarbs kylecarbs self-assigned this Jan 22, 2022
@codecov
Copy link

codecov bot commented Jan 22, 2022

Codecov Report

Merging #49 (05ded12) into main (dfddaf1) will decrease coverage by 0.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
- Coverage   71.31%   71.12%   -0.20%     
==========================================
  Files          59       59              
  Lines        2308     2327      +19     
  Branches       30       30              
==========================================
+ Hits         1646     1655       +9     
- Misses        517      525       +8     
- Partials      145      147       +2     
Flag Coverage Δ
unittest-go-macos-latest 65.90% <36.84%> (-0.84%) ⬇️
unittest-go-ubuntu-latest 70.18% <100.00%> (+0.18%) ⬆️
unittest-go-windows-latest 65.74% <36.84%> (-0.25%) ⬇️
unittest-js 74.91% <ø> (ø)
Impacted Files Coverage Δ
coderd/coderdtest/coderdtest.go 100.00% <100.00%> (ø)
peer/channel.go 87.11% <100.00%> (+0.16%) ⬆️
peer/conn.go 75.74% <100.00%> (-0.55%) ⬇️
peerbroker/dial.go 72.72% <0.00%> (-4.55%) ⬇️
peerbroker/listen.go 80.46% <0.00%> (-2.35%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfddaf1...05ded12. Read the comment docs.

- name: Test with PostgreSQL Database
if: runner.os == 'Linux'
run:
DB=true gotestsum --jsonfile="gotests.json" --packages="./..." --
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! It's neat that it's so easy to test both ways.

I like that we get the best of both worlds here - the mock DB seems ideal for quick iteration because it's so fast, but testing against a real PostgreSL driver is important too, but doesn't have to slow down test authoring.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@@ -86,13 +86,14 @@ INSERT INTO
email,
name,
login_type,
revoked,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem related to the ability to switch between DB / mock - but maybe needed to be updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this was actually a bug the DB implementation caught!

Not all resources were cleaned up immediately after a peer connection was
closed. DataChannels could have a goroutine exit after Close() prior to this.
@@ -135,6 +135,7 @@ func (c *Channel) init() {

c.conn.dcDisconnectListeners.Add(1)
c.conn.dcFailedListeners.Add(1)
c.conn.dcClosedWaitGroup.Add(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on these! Looks like a candidate for a backport to cdr/m too - seems like we're missing this wait logic there too

@kylecarbs kylecarbs enabled auto-merge (squash) January 22, 2022 21:55
@kylecarbs kylecarbs merged commit 50d8151 into main Jan 22, 2022
@kylecarbs kylecarbs deleted the cidb branch January 22, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants