How do you test your Rails app on Fly?

Hey everyone,

I am trying to conceptualize an approach to testing my Rails application on Fly. Specifically, end-to-end “system” tests.

The scenario:
My Rails application uses a few APIs (Fly, payment provider, IPLocate), communicates with an OpenResty (Nginx) gateway and an FTP server in the same fly org and acts on webhooks received from the payment provider. I already set up two environments on fly (production and staging) both working fine. Until now, I use the staging env to do a few tests manually with test cards for “test-mode”-payments. The staging env creates real fly machines just like the production env and the nginx gateway routes traffic to those.

The challenge:
Running rails test locally (dev PC) is okay for unit tests, but not for system tests, where I want to test that the payment integration works (requests sent, webhooks received), fly machines are created and made accessible (or blocked) through the gateway, that the rails app orchestrates all that, etc.
Technically, I could deploy to staging, run tests locally and tell capybara (selenium) to do the system tests against the staging app running on fly. That would probably be the easiest way. But the local rails running the tests won’t be able to do assertions against what is in the database, because it uses a test DB, while the system-tested staging app uses a staging DB.
Another way would be to create yet another environment on fly (and in the payment provider) for the testing purposes, but that could be somewhat overkill: Postgres and Redis instances could probably be the same as for staging, but still I’d need another 2 machines for rails, one for the FTP server, one for the nginx gateway, also another domain, wildcard SSL certificate, … you get the idea.

Does anyone have an idea on how to approach this?

Maybe something like repurposing the staging env for tests? But how would I run the full testing on fly and keep the option to run the staging app also?

Any ideas are greatly appreciated!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.