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

Flag for persisting variables #2084

Closed
wants to merge 1 commit into from

Conversation

agraven
Copy link

@agraven agraven commented Oct 22, 2023

Add --persist flag which will result in changed variables being saved to the variables-file.

While it works in practice, I have yet to test how this handles any edge cases, and this more serves as a general outline for an implementation approach. I'll happy polish this further if there's maintainer interest in this approach.

Relates to #1208 and #1977

Add --persist flag which will result in changed variables being saved to
the variables-file.
@jcamiel
Copy link
Collaborator

jcamiel commented Oct 23, 2023

Hi @agraven,

Thanks for proposing this PR!

For the moment, I'll postpone this PR: to address this feature, we're thinking about implementing --write-out from curl. This feature would be used to change the default sdtout: usually the last HTTP response is outputed from Hurl. If you want to output the HTTP server header instead of the response:

GET https://foo.com
[Options]
write-out: "Server: %header{server}"
HTTP 200

When run:

$ hurl foo.hurl
Server: Flask

We think about adding variable to the variables used in the write-out. This way, you'll be able to "dump" the variable state of your Hurl file if you want.

I just need to confirm with the others two maintainers what we want to do (@fabricereix @lepapareil )

@agraven
Copy link
Author

agraven commented Oct 24, 2023

The limitation of what the approach you're suggesting, assuming I've understood it correctly, is that you can't keep a persistent environment across multiple files in a single invocation. In other words, it's possible to do hurl foo.hurl > vars && hurl bar.hurl --variables-file vars with your example above, where bar.hurl is a hurl file that depends on a variable defined by foo.hurl. But you couldn't do hurl foo.hurl bar.hurl, which the approach of this PR would allow.

@jcamiel
Copy link
Collaborator

jcamiel commented Oct 24, 2023

Yes, but we also prepare works for long standing issues on running Hurl file in parallel (see the first issues on Hurl that we want to address #87 #88).

With theses features, we want to be able to run:

$ hurl --parallel foo.hurl bar.hurl

For the moment, in the code, there is no mutable state between files execution. We need to, at most possible, limit the shared state between files executions so implementing parallel runs will be easier. That's why we're cautious on these features (even if there are important).

@SilenLoc
Copy link

SilenLoc commented Nov 24, 2023

@agraven if you care a lot about persisting values in between:
I made some experiments with spinning up a server that just saves whatever key/value I give it, you could use also a local instance of https://github.com/charmbracelet/skate but in the end it is just a remote map.

Then you just use hurl to save x - y and then later you retrieve it again with hurl by doing a get and capture the value.

You can even wait by retrying to get the value to start certain tests.

I composed it with "just runner":

  • start actual test target
  • start remote map / skate
  • run your tests

@jcamiel jcamiel marked this pull request as draft December 21, 2023 20:30
@jcamiel jcamiel changed the title Draft: Flag for persisting variables Flag for persisting variables Dec 21, 2023
@hurl-bot
Copy link
Collaborator

📆 This PR has been closed because there is no activity (commits/comments) for more than 30 days 😥. Feel free to reopen it with new commits/comments.

@hurl-bot hurl-bot closed this Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants