-
Notifications
You must be signed in to change notification settings - Fork 556
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
Detect custom OpenAPI spec file and start stripe-mock from test suite #715
Conversation
And of course the subprocess gem doesn't work with JRuby :( |
bd28fe0
to
5ace43d
Compare
Alright, went for a slightly different approach. The test suite now checks if The idea is that on CI, we'd manually start stripe-mock and set Let me know what you think! If you think this is a good approach, I'll update the README file accordingly. |
5ace43d
to
edc57d7
Compare
edc57d7
to
4894de8
Compare
8773c0f
to
7e72087
Compare
.travis.yml
Outdated
-http-port ${STRIPE_MOCK_PORT} \ | ||
-spec test/openapi/spec3.json \ | ||
-fixtures test/openapi/fixtures3.json \ | ||
> /dev/null & |
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.
Just wanted to make sure, but I assume that this is an artifact of an older attempt? It seems to be running basically the same thing as Stripe::StripeMock
.
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.
Ah, I saw your note about running differently in CI. Still not sure I 100% understand the expected workflow here, but I'll leave that in a comment below.
@ob-stripe Thanks for taking a stab here! Sorry about the super late reply :/ First of all: I just want to get a general idea of the suggested workflow here. Is the idea that If so, I wonder if we should just have a single override flag somewhere for use in CI that boots an automatic stripe-mock (like you get locally), but requires minimal changes to And sorry, but just a couple other points of FUD for completeness:
|
859f6bf
to
586d503
Compare
I don't feel super strongly about it but I'd personally lean towards having everything in master, for consistency and to make it easier to deal with multiple betas in parallel. It would also make it easier to identify the exact surface of a specific beta, by looking at the diff for the spec.
Good point. I just copied the raw files for simplicity's sake, but we could also use a git submodule like in stripe-mock.
👍 I've updated the PR to remove the dependency on |
Oh I see. So the current (non-alpha/beta/etc.) OpenAPI spec is in
K cool. Not saying we should do that for sure because as discussed before, submodules are a pain, but I'm a little afraid that we eventually go through enough iterations on the spec that we end up accidentally making the repo pretty heavyweight.
Awesome! This is wayyyy better. Just reading this over, it looks to me that when running the test suite locally, a new version of stripe-mock is always started, even on the master branch (unless you have |
586d503
to
949b3e7
Compare
Yeah exactly. This way you'd have all the information in one place when looking at the diff between the beta branch and
We've often run into issues where some tests would fail after upgrading your local instance of stripe-mock (e.g. after running If we don't do this though, how would you recommend checking for master vs. beta branch? We could either just have different code in the beta branches, or do something like |
Yep, makes sense.
Those failures are generally well-documented at least right? As in, the test suite fails with "the minimum stripe-mock needed is X.X.X". (I'm not sure if there's some other type of "upgrade failure" that I can't think of.) I sort of like the idea of continuing to fall back to the system's stripe-mock as much as possible just to keep things really, really fast. The test suites for languages like Ruby and Go are fast enough now that launching a new process every time would be a noticeable slow down. There also may be that problem of Mac OS popping up the "stripe-mock allow like to listen on port XXX, allow/deny" dialog all the time which would be pretty annoying.
Hm, a Git-based solution seems relatively plausible — I'd probably suggest a chance to your approach a bit by checking whether the current branch has any modifications in the directory containing the OpenAPI specs. That way non-beta branches on both your local machine and in CI could continue to use system stripe-mock. I also think that it might not be that bad to make the launch explicit on beta branches. As in we add a line that's normally commented out like: # Uncomment for an alpha/beta branch that need stripe-mock to use custom OpenAPI.
# Stripe::StripeMock.start Admittedly though, there'd always be risk of it being accidentally merged to master. |
802de09
to
722c9cb
Compare
722c9cb
to
dbf8a41
Compare
Okay, I've updated the PR with your feedback. Now the test suite looks for a This way, we can merge this PR into ptal @brandur-stripe |
Nice! LGTM. I'm really liking not having the spec bundled in |
Alright, thanks @brandur-stripe! Pulling this in. |
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
Very similar to the recent feature implemented in other languages (for example [1]), this wraps test runs in a script which will detect a custom OpenAPI spec and fixture in `testing/openapi/` and start a local version of stripe-mock pointing to them. The test suite is then executed against that stripe-mock and it's shut down afterwards. If there isn't a custom OpenAPI spec, we continue to fall back to the system stripe-mock to keep test runs as fast as possible. This differs a little from implementations in other languages in that we had to start stripe-mock from a script (as opposed to a `before` block or the like) because Go's testing tools don't give us a place where we can do anything before any test runs. Therefore, we start stripe-mock then execute `go test ./...` as a subprocess. [1] stripe/stripe-ruby#715
r? @brandur-stripe @remi-stripe
First attempt at embedding OpenAPI spec and fixtures files directly in the repo and using those for the test suite. Pretty rough, but it works.
Possible improvements:
better logs / error handling(done)automatically choose an unused port(done)