-
Notifications
You must be signed in to change notification settings - Fork 795
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
Testing guide #1584
Testing guide #1584
Conversation
💯 Added some comments and suggestions, I really like the general explanation followed by a concrete example! |
The `docker-compose.yml` file defines the following: | ||
|
||
- The Postgres image (`postgres`) and version tag (`:13`). This will be downloaded if you do not have it locally available. | ||
- The port `5433` is mapped to the internal (Postgres default) port `5432`. This will be the port number the database is exposed on externally. |
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.
Why not mapping both to 5432
?
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 had issues with this and found that chaging the port solved it. I was going to document that but i cant find the reason why it didnt work. I though people might ask that exact question though....
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 think it only helps if you already have a PostgreSQL database service started locally, Then the 5432 port is already occupied and Docker cannot use it.
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.
Ohhh. Hmm. But i dont have anything else running on that port, i checked. Lemme double check again now and change port. It would make much more sense to map to the same port as thats what people expect too
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.
Yep, it doesnt work for me. I cant authenticate
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.
Docker compose logs probably show something about the port if it's already used / cannot be used
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.
Nope, not that i can see at least
$ docker-compose logs -f -t
Attaching to integration-tests-prisma
integration-tests-prisma | 2021-05-12T09:27:28.866263300Z The files belonging to this database system will be owned by user "postgres".
integration-tests-prisma | 2021-05-12T09:27:28.866310600Z This user must also own the server process.
integration-tests-prisma | 2021-05-12T09:27:28.866314000Z
integration-tests-prisma | 2021-05-12T09:27:28.866316600Z The database cluster will be initialized with locale "en_US.utf8".
integration-tests-prisma | 2021-05-12T09:27:28.866319000Z The default database encoding has accordingly been set to "UTF8".
integration-tests-prisma | 2021-05-12T09:27:28.866321400Z The default text search configuration will be set to "english".
integration-tests-prisma | 2021-05-12T09:27:28.866323500Z
integration-tests-prisma | 2021-05-12T09:27:28.866325500Z Data page checksums are disabled.
integration-tests-prisma | 2021-05-12T09:27:28.866327500Z
integration-tests-prisma | 2021-05-12T09:27:28.866329400Z fixing permissions on existing directory /var/lib/postgresql/data ... ok
integration-tests-prisma | 2021-05-12T09:27:28.867173800Z creating subdirectories ... ok
integration-tests-prisma | 2021-05-12T09:27:28.867261600Z selecting dynamic shared memory implementation ... posix
integration-tests-prisma | 2021-05-12T09:27:28.878419700Z selecting default max_connections ... 100
integration-tests-prisma | 2021-05-12T09:27:28.892358200Z selecting default shared_buffers ... 128MB
integration-tests-prisma | 2021-05-12T09:27:28.906787900Z selecting default time zone ... Etc/UTC
integration-tests-prisma | 2021-05-12T09:27:28.908146800Z creating configuration files ... ok
integration-tests-prisma | 2021-05-12T09:27:29.018818300Z running bootstrap script ... ok
integration-tests-prisma | 2021-05-12T09:27:29.350018100Z performing post-bootstrap initialization ... ok
integration-tests-prisma | 2021-05-12T09:27:29.685673500Z syncing data to disk ... ok
integration-tests-prisma | 2021-05-12T09:27:29.685710500Z
integration-tests-prisma | 2021-05-12T09:27:29.685714600Z
integration-tests-prisma | 2021-05-12T09:27:29.685717100Z Success. You can now start the database server using:
integration-tests-prisma | 2021-05-12T09:27:29.685719400Z
integration-tests-prisma | 2021-05-12T09:27:29.685721500Z pg_ctl -D /var/lib/postgresql/data -l logfile start
integration-tests-prisma | 2021-05-12T09:27:29.685723700Z
integration-tests-prisma | 2021-05-12T09:27:29.685676500Z initdb: warning: enabling "trust" authentication for local connections
integration-tests-prisma | 2021-05-12T09:27:29.685731400Z You can change this by editing pg_hba.conf or using the option -A, or
integration-tests-prisma | 2021-05-12T09:27:29.685733500Z --auth-local and --auth-host, the next time you run initdb.
integration-tests-prisma | 2021-05-12T09:27:29.720693100Z waiting for server to start....2021-05-12 09:27:29.720 UTC [47] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
integration-tests-prisma | 2021-05-12T09:27:29.727427800Z 2021-05-12 09:27:29.727 UTC [47] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
integration-tests-prisma | 2021-05-12T09:27:29.750927700Z 2021-05-12 09:27:29.750 UTC [48] LOG: database system was shut down at 2021-05-12 09:27:29 UTC
integration-tests-prisma | 2021-05-12T09:27:29.759384400Z 2021-05-12 09:27:29.759 UTC [47] LOG: database system is ready to accept connections
integration-tests-prisma | 2021-05-12T09:27:29.794525900Z done
integration-tests-prisma | 2021-05-12T09:27:29.794544600Z server started
integration-tests-prisma | 2021-05-12T09:27:30.064517200Z CREATE DATABASE
integration-tests-prisma | 2021-05-12T09:27:30.065018600Z
integration-tests-prisma | 2021-05-12T09:27:30.065259400Z
integration-tests-prisma | 2021-05-12T09:27:30.065299300Z /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
integration-tests-prisma | 2021-05-12T09:27:30.065302600Z
integration-tests-prisma | 2021-05-12T09:27:30.066200200Z 2021-05-12 09:27:30.066 UTC [47] LOG: received fast shutdown request
integration-tests-prisma | 2021-05-12T09:27:30.073528400Z waiting for server to shut down....2021-05-12 09:27:30.073 UTC [47] LOG: aborting any active transactions
integration-tests-prisma | 2021-05-12T09:27:30.074529600Z 2021-05-12 09:27:30.074 UTC [47] LOG: background worker "logical replication launcher" (PID 54) exited with exit code 1
integration-tests-prisma | 2021-05-12T09:27:30.074697000Z 2021-05-12 09:27:30.074 UTC [49] LOG: shutting down
integration-tests-prisma | 2021-05-12T09:27:30.116218600Z 2021-05-12 09:27:30.116 UTC [47] LOG: database system is shut down
integration-tests-prisma | 2021-05-12T09:27:30.166455500Z done
integration-tests-prisma | 2021-05-12T09:27:30.166491000Z server stopped
integration-tests-prisma | 2021-05-12T09:27:30.166639300Z
integration-tests-prisma | 2021-05-12T09:27:30.166648100Z PostgreSQL init process complete; ready for start up.
integration-tests-prisma | 2021-05-12T09:27:30.166650900Z
integration-tests-prisma | 2021-05-12T09:27:30.194092700Z 2021-05-12 09:27:30.193 UTC [1] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
integration-tests-prisma | 2021-05-12T09:27:30.194232400Z 2021-05-12 09:27:30.194 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
integration-tests-prisma | 2021-05-12T09:27:30.194335400Z 2021-05-12 09:27:30.194 UTC [1] LOG: listening on IPv6 address "::", port 5432
integration-tests-prisma | 2021-05-12T09:27:30.208729200Z 2021-05-12 09:27:30.208 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
integration-tests-prisma | 2021-05-12T09:27:30.224341600Z 2021-05-12 09:27:30.224 UTC [75] LOG: database system was shut down at 2021-05-12 09:27:30 UTC
integration-tests-prisma | 2021-05-12T09:27:30.234287700Z 2021-05-12 09:27:30.234 UTC [1] LOG: database system is ready to accept connections
This PR create sa new
Testing guide
section which has 2 new pages:The Unit testing page covers why and when to unit test as well as mocking the client using a singleton and depencency injection patterns, plus a couple of examples of actual unit test.
The Integration testing page covers setting up and using Docker to house a database to test against. It also includes soem examples of integration tests.
Fixes: #1293
Fixes: 5014