aquariumbio / aquarium

The Aquarium Lab Operating System
http://klavinslab.org/aquaverse/
MIT License
58 stars 15 forks source link

V3 docker cypress #574

Closed bjkeller closed 3 years ago

bjkeller commented 3 years ago

Makes changes focused on improving how Cypress end-to-end testing is run.

Changes the end-to-end tests to use the backend running with the test database rather than development. Specifically, reorganized services so that the end-to-end tests could be run either while the development services are running – mainly by parameterizing the frontend, using an alternate database service, and ensuring that the ports do not conflict. The test services can also be run with a new script bin/aquarium-test.sh that is analogous to running the development services with docker-compose commands. The test database is reset and reseeded when the backend_test service starts.

(Note: the backend service is hardcoded in the end2end/cypress/support/commands.js b/c environment variable is not available.)

bjkeller commented 3 years ago

@marikoja this should be ready to go.

I did change the neptune password to aquarium123 to meet the new length constraint. that user is only available in development For test, the user is test_user. So if you run with ./bin/aquarium-test.sh that is the user you would login with.

There were 6 failures when I ran the end-to-end tests, but since that just indicates failure I didn't look at them in detail

bjkeller commented 3 years ago

see #572

gnomicosuw commented 3 years ago

We should be using the six users that we agreed to from test_seeds.rb. That way the test_database + Rspec backend + cypress frontend will all remain all in sync

user_admin user_manage user_run user_design user_develop user_retired

So wherever we have been using "neptune" we should just replace the tests with "user_admin"

bjkeller commented 3 years ago

So, tests wouldn't modify that user?

gnomicosuw commented 3 years ago

Ben, I thought you had merged the latest v3_database into v3-docker-cypress, but it does not look like that has been done? Can you do that before we merge this PR? The latest v3_database has the following changes:

user_admin user_manage user_run user_design user_develop user_retired

It is totally fine to add the "neptune" user to the list, but in reality you don't need to (just use the "user_admin" one instead). Those users do not get changed by the tests (and they get re-generated at the beginning of each run, anyway)

bjkeller commented 3 years ago

Ben, I thought you had merged the latest v3_database into v3-docker-cypress, but it does not look like that has been done? Can you do that before we merge this PR?

Yes, it is already merged. I changed how the seeds are created to make them idempotent, but didn't change the specs.

See https://github.com/aquariumbio/aquarium/blob/0efd5311af4e7576c779fd28eeac5285451994be/backend/db/test_seeds.rb#L21

gnomicosuw commented 3 years ago

Got it. For some reason when I checked out the v3-docker-cypress branch it did not give me the latest. That was weird, even though it said it v3-docker-cypress matched origin/v3-docker-cypress. I did a "git pull origin v3-docker-cypress" and that updated everything.

My bad. I will review the branch over the weekend.

gnomicosuw commented 3 years ago

I don't think we should merge this branch without also fixing the mimemagic / Rails issue that came up last week. Yes, they are kind of unrelated, but until the mimemagic fix is pushed you cannot run Rspec or even build anything. (And technically we should not push anything in which the tests do not pass.)

For example. if you try to run Rspec you get "Could not find mimemagic-0.3.5 in any of the sources"

Right now the mimemagic fix is a commit on the v3_manager branch. I assume we can cherry-pick that commit into this branch, I will try it on Monday.

bjkeller commented 3 years ago

@gnomicosuw How about you pull those changes into v3-refactor with checkout?

see, e.g., http://nicolasgallagher.com/git-checkout-specific-files-from-another-branch/

gnomicosuw commented 3 years ago

It is easier to just do a git cherry-pick.

gnomicosuw commented 3 years ago

Just cherry-picked the mimemagic fix and pushed to v3-docker-cypress. The Rspec tests all pass.

If the frontend tests pass I am good to merge this into v3-refactor. Ben and Mariko, I’ll leave it to you.

p.s. I know I am a broken record, but I still think we need to fix the interceptors and actually intercept 4xx errors. For example, on a session timeout it is way to easy to get a page with no results and think there are no results (vs. not realizing that your session has timed out…)

marikoja commented 3 years ago

@bjkeller I can run aquarium against the test bd and test using npx cypress open as long as I add "baseUrl": "http://localhost:3001", to the cypress.json file.

I cannot run aquarium normally AND the test services due to port 3001. The following is from my terminal first running docker-compose up then bin/aquarium-test.sh up

docker-compose -f docker-compose.yml -f docker-compose.test-db.yml -f docker-compose.test.yml up WARNING: Found orphan containers (aquarium_backend_1, aquarium_frontend_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. Recreating aquarium_db_1 ... done Creating aquarium_backend_test_1 ... done Creating aquarium_frontend_test_1 ... Creating aquarium_frontend_test_1 ... error

ERROR: for aquarium_frontend_test_1 Cannot start service frontend_test: driver failed programming external connectivity on endpoint aquarium_frontend_test_1 (292b2d30ca57e7a13cddf242d5feeb41fadcd008aca6b2edf428d6b67fbd3867): Bind for 0.0.0.0:3001 failed: port is already allocated

ERROR: for frontend_test Cannot start service frontend_test: driver failed programming external connectivity on endpoint aquarium_frontend_test_1 (292b2d30ca57e7a13cddf242d5feeb41fadcd008aca6b2edf428d6b67fbd3867): Bind for 0.0.0.0:3001 failed: port is already allocated ERROR: Encountered errors while bringing up the project.

bjkeller commented 3 years ago

@marikoja if the only services you have running are from those two commands, you should not have a conflict b/c only one service is set to use 3001 (frontend_test). You could be getting a conflict if you have something else running that has 3001.

You will probably have to run

rm -rf .env*
./bin/setup.sh

to make sure your environment is correct

Also, the configuration requires that docker/mysql_init/grant_aquarium_development.sql and docker/mysql_init/create_aquarium_test.sql have both been loaded as the db root. You can either do this with the command line, or by running docker-compose down -v before starting so that the databases will be forced to be rebuilt.

bjkeller commented 3 years ago

there may be weird errors because these configurations share the same network and database

bjkeller commented 3 years ago

someday I'll figure out why GitHub doesn't pickup squash merges done locally.

anyway, merged, so I'm closing