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 rack_url_scheme to Puma::DSL, allows setting of rack.url_scheme header #2586

Merged
merged 3 commits into from May 26, 2021

Conversation

MSP-Greg
Copy link
Member

@MSP-Greg MSP-Greg commented Mar 26, 2021

Description

Closes #2569.

Your checklist for this pull request

  • I have reviewed the guidelines for contributing to this repository.
  • I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
  • My pull request is 100 lines added/removed or less so that it can be easily reviewed.
  • If this PR doesn't need tests (docs change), I added [ci skip] to the title of the PR.
  • If this closes any issues, I have added "Closes #issue" to the PR description or my commit messages.
  • I have updated the documentation accordingly.
  • All new and existing tests passed, including Rubocop.

@nateberkopec nateberkopec added the waiting-for-review Waiting on review from anyone label Mar 29, 2021
@nateberkopec nateberkopec added this to the 5.3.0 milestone Apr 24, 2021
@nateberkopec
Copy link
Member

I would've appreciated the test refactoring as a separate (or several) separate PRs 😫

sleep 0.01
end

def rack_env_to_body
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test fixture, and as such should be defined in the test that uses it, IMO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below. After these are in the repo, other test files can be rewritten (and simplified) by using these fixtures.


def rack_url_scheme(val)
start_server rack_env_to_body
assert_includes fast_connect_get_body.lines, "rack.url_scheme: #{val}\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a higher-level assert:

assert_body_includes "rack.url_scheme"

...so test writers don't have to understand fast_connect_get_body.lines

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

test/test_rack_env.rb Outdated Show resolved Hide resolved
}
end

def ci_test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is not used in this pull request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

svr_in_proc.rb is a generic fixture file. See below.


# Generates the request/response time distribution string
#
def time_info(threads, clients_per_thread, time_ary, req_per_client = 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used in the PR?

@nateberkopec
Copy link
Member

If you could remove everything from this PR that's not actually used in this PR, that would help me a lot to understand what's going on.

The whole approach and changes are 💯 but I can't follow everything when there's so much to sort through.

@MSP-Greg
Copy link
Member Author

MSP-Greg commented May 5, 2021

All the files in test/helpers are intended to be test fixture files. These are part of the test rewrite I've been using for while, and I've also mentioned.

This PR includes some of them, and uses them to for the new test file 'test_rack_env.rb'. PR #2595 'Improve client response code, chunked bodies', also uses sockets.rb in the benchmark files, along with some new rackup files.

Re the helper files:

sockets.rb is a fixture for creating client sockets, whether a single client or a stream of them. It shares variables with svr_in_proc.rb, which is used to create in-process Server instances.

So, these fixtures can be used to simplify test_puma_server, test_puma_server_ssl, etc. I've got a few test files I've converted to the new system, but those files are not in this PR.

A file that isn't in this PR is svr_popen.rb, which creates instances of Puma via IO.popen. I do have the integration tests converted to the new system.

So, rather than a huge PR with a whole new test system, I thought adding the fixtures operating on one test file would be a good first step. I expect they will evolve, have more comments added, etc. I think I started a 'Test Fixture Overview` markdown file also.

EDIT: Sorry I thought I rebased this recently. Just rebased...

@MSP-Greg MSP-Greg force-pushed the rack-url-scheme branch 2 times, most recently from 5aaf852 to 78c7836 Compare May 5, 2021 04:18
@MSP-Greg
Copy link
Member Author

MSP-Greg commented May 5, 2021

@nateberkopec

#2620 is a new PR with only the test fixture files in it. If you're okay with merging it, I'll remove them from this PR?

@nateberkopec nateberkopec removed the waiting-for-review Waiting on review from anyone label May 6, 2021
@nateberkopec nateberkopec removed this from the 5.3.0 milestone May 6, 2021
@nateberkopec nateberkopec added the waiting-for-changes Waiting on changes from the requestor label May 17, 2021
@MSP-Greg
Copy link
Member Author

Removed the additional test files, added two tests to test_puma_server.rb...

@nateberkopec nateberkopec added waiting-for-review Waiting on review from anyone and removed waiting-for-changes Waiting on changes from the requestor labels May 26, 2021
@nateberkopec nateberkopec merged commit 32852f7 into puma:master May 26, 2021
@MSP-Greg MSP-Greg deleted the rack-url-scheme branch November 3, 2021 15:05
JuanitoFatas pushed a commit to JuanitoFatas/puma that referenced this pull request Sep 9, 2022
…eader (puma#2586)

* Add rack_url_scheme to Puma::DSL, allows setting of rack.url_scheme header

* Clarify comment on DSL re: rack URL

* Add tests to test_puma_server.rb

Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature waiting-for-review Waiting on review from anyone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add config option to manually define Rack url scheme
2 participants