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

Add ability to reset the database #46

Merged
merged 1 commit into from
Jun 21, 2022
Merged

Add ability to reset the database #46

merged 1 commit into from
Jun 21, 2022

Conversation

nicholasray
Copy link
Contributor

The ability to reset the database before a test group runs can be necessary when
using previous branch (e.g. when using the -b flag) as that code may assume an
older database schema structure that the database may not have.

Resetting the db will also become critical when tests are introduced that make
changes to the database (e.g. tests that edit an article ). Providing this flag
enables the ability for each test group to be completely isolated from the side
effects that another test group may cause.

Additionally:

  • Update database seed file to database_2022-06-13_12-27-44-0600(MDT).tar.gz
    to fix crash messages appearing in the mysql logs.

  • Revise db:save npm script to enable "slow shutdown" of mysql prior to taking a physical backup. Mysql states this is needed in their docs [1]

  • Revise healthcheck logic in docker compose after noticing the healthcheck
    reporting that the db was healthy when it wasn't accepting any connections yet.
    Relying on a status query for the my_wiki should be more reliable.

[1] https://dev.mysql.com/doc/refman/8.0/en/innodb-backup.html

The ability to reset the database before a test group runs can be necessary when
using previous branch (e.g. when using the `-b` flag) as that code may assume an
older database schema structure that the database may not have.

Resetting the db will also become critical when tests are introduced that make
changes to the database (e.g. tests that edit an article ). Providing this flag
enables the ability for each test group to be completely isolated from the side
effects that another test group may cause.

Additionally:

* Update database seed file to `database_2022-06-13_12-27-44-0600(MDT).tar.gz`
to fix `crash` messages appearing in the mysql logs.

* Revise `db:save` npm script to enable "slow shutdown" of mysql prior to taking a physical backup. Mysql states this is needed in their docs [1]

* Revise healthcheck logic in docker compose after noticing the healthcheck
reporting that the db was healthy when it wasn't accepting any connections yet.
Relying on a `status` query for the my_wiki should be more reliable.

[1] https://dev.mysql.com/doc/refman/8.0/en/innodb-backup.html
@jdlrobson
Copy link
Member

I went to http://localhost:3000/wiki/Main_Page and edited the page. After running npm run db:save I'm still seeing the edited main page. Is that intentional?

@nicholasray
Copy link
Contributor Author

nicholasray commented Jun 21, 2022

I went to http://localhost:3000/wiki/Main_Page and edited the page. After running npm run db:save I'm still seeing the edited main page. Is that intentional?

Yes. This commit's main focus was adding a --reset-db flag that you can use with the reference (e.g. ./pixel.js reference --reset-db) or the test command (e.g. ./pixel.js test --reset-db) to reset any database changes you've made or a test has made.

For example, if a test group were to edit the Test page but you didn't want those database changes to bleed into the next test group, you could run ./pixel.js reference --reset-db -g ... and it should reset the database to the original seed data.

It also adds a reset-db command that you can use to reset the database yourself (e.g. ./pixel.js reset-db). If you edit a page, and then run that command, it should reset the database to the original seed data.

@jdlrobson
Copy link
Member

Now getting:

rsync: change_dir "/var/lib/mysql_backup" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
(node:24963) UnhandledPromiseRejectionWarning: Error: Exit with error code 23
    at ChildProcess.<anonymous> (/Users/jrobson/git/pixel/src/BatchSpawn.js:70:13)
    at ChildProcess.emit (events.js:400:28)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24963) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24963) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@nicholasray
Copy link
Contributor Author

nicholasray commented Jun 21, 2022

Now getting:

rsync: change_dir "/var/lib/mysql_backup" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
(node:24963) UnhandledPromiseRejectionWarning: Error: Exit with error code 23
    at ChildProcess.<anonymous> (/Users/jrobson/git/pixel/src/BatchSpawn.js:70:13)
    at ChildProcess.emit (events.js:400:28)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24963) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24963) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Since this patch changes the database docker image, you'll need to run./pixel.js clean so that the database image can be rebuilt. Please note that running this command will destroy any data you currently have in the database

@jdlrobson jdlrobson merged commit cef75f3 into main Jun 21, 2022
@nicholasray nicholasray deleted the reset-db branch March 23, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants