-
Notifications
You must be signed in to change notification settings - Fork 19
Conversation
8ea6227
to
1d26964
Compare
Codecov Report
@@ Coverage Diff @@
## master #171 +/- ##
==========================================
- Coverage 62.38% 62.11% -0.28%
==========================================
Files 43 43
Lines 2289 2307 +18
==========================================
+ Hits 1428 1433 +5
- Misses 592 602 +10
- Partials 269 272 +3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about a lot of this and if we really need to do this. Our apps need to be uniform and work under go test
with minimal configuration otherwise.
func runCmd(cmd string, config *Config) error { | ||
switch cmd { | ||
case "setup": | ||
err := dropDB(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot drop the database. This needs to never be an option in production in fact we will not grant a service DROP
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tests this may be useful. For example if you want to test some specific migrations, etc. We can add -force flag for drop and make it work only if database has _test
.
Sorry this is a big comment. I'm against this right now. I understand we have slow tests when running
Questions
Summary We need to keep our services fairly similar amongst each other. Otherwise our repositories will sprawl with how they operate and that causes additional developer headaches. |
@@ -31,6 +33,10 @@ func TestMySQL__basic(t *testing.T) { | |||
if conn != nil || err == nil { | |||
t.Fatalf("conn=%#v expected error", conn) | |||
} | |||
|
|||
fmt.Println("Hello") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this :)
The goal of this PR is to decrease time we spend waiting for a test results and make us more productive. Currently on my machine running all tests takes ~2m:50s. This makes me run tests less frequently or rely on CI (which takes even more time because it runs linters, etc.). Main time consuming part of our system is testing with MySQL. Specifically: run docker container with MySQL and run migrations. We do this multiple times if we run full test suite.
Here is how we can speedup our tests:
This PR does all this changes. On my machine running all tests takes 9s now.
Here is how you can get it:
Let's discuss what's the best way for us to make it convenient to run tests with local instances vs with dockertest.
Also, as a side effect new binary that allows us to manage db was introduced:
All commands works with default MySQL config and may be updated with environment variables:
This is used for testing, but I truly believe it should be used in production as well. Why? Currently we run migrations when we start server (inside Connect method). When we have multiple instances of customers (for HA) each of them will run migrations and in case of simultaneous run it may result in an error and failure to start server.