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

fix the bug #2799, add prefix (?i) in rewrite statement. #2808

Merged
merged 1 commit into from
Aug 3, 2018
Merged

fix the bug #2799, add prefix (?i) in rewrite statement. #2808

merged 1 commit into from
Aug 3, 2018

Conversation

teresadq
Copy link

@teresadq teresadq commented Jul 18, 2018

the location in nginx.conf is case insensitive, but when we use the annotation nginx.ingress.kubernetes.io/rewrite-target in ingress rule. the rewrite statement is case sensitive. so we can fix this bug in adding (?i) in rewrite statement.

fixes #2799

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 18, 2018
@teresadq
Copy link
Author

@antoineco Hi, please check it.

@aledbf
Copy link
Member

aledbf commented Jul 18, 2018

@dongqi1990 please add e2e tests for this change. Thanks

@teresadq
Copy link
Author

teresadq commented Jul 18, 2018

@aledbf ok, You means that I should modify the rewrite statement in template_test.go, like "rewrite /something/(.*) /$1 break;" in "tmplFuncTestcases" (e.g. changing "rewrite /something/(.*) /$1 break;" to "rewrite (?i)/something/(.*) /$1 break;")? Otherwise the go test doesn't pass.

@aledbf
Copy link
Member

aledbf commented Jul 18, 2018

No, I mean, you need to add new e2e tests to check this works with a running ingress controller. Doing unit tests for this is not enough.

@aledbf
Copy link
Member

aledbf commented Jul 18, 2018

Also, you need to change the mentioned unit tests

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 19, 2018
@codecov-io
Copy link

Codecov Report

Merging #2808 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2808   +/-   ##
=======================================
  Coverage   47.47%   47.47%           
=======================================
  Files          75       75           
  Lines        5413     5413           
=======================================
  Hits         2570     2570           
  Misses       2519     2519           
  Partials      324      324
Impacted Files Coverage Δ
internal/ingress/controller/template/template.go 66.52% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48ee93f...8da4594. Read the comment docs.

@teresadq
Copy link
Author

@aledbf @antoineco I had modify the unit test template_test.go and e2e test file rewrite_log.go. Please check it.

@antoineco
Copy link
Contributor

Thanks for that. We also need to test this with an actual HTTP request (see other e2e examples), eg. with capital letters in the request, and assert the response looks as expected.

@teresadq
Copy link
Author

teresadq commented Jul 19, 2018

@antoineco OK, I had two question to ask you.

  1. Could you give me some reference material about e2e test. I am not familiar with it. Thank you.
  2. Did I need to new file in e2e folder? If I add new feature like nginx cache or other features in nginx level 4.

@antoineco
Copy link
Contributor

antoineco commented Jul 26, 2018

@dongqi1990 sorry I totally missed your response! 🙇

I don't have formal instructions for writing e2e tests but if you look in the directory you mentioned you will find out that all tests follow the same logic:

  • create an Ingress + echoheaders backend
  • set annotation(s) on Ingress
  • wait for NGINX config refresh
  • send HTTP request to NGINX
  • assert the result using a Gomega matcher

I can adapt the test for you if you want to see how I would do it, or do you prefer to give it a try yourself?

@teresadq
Copy link
Author

teresadq commented Jul 26, 2018

@antoineco Thank you very much for your kindness. I had ran the e2e test in my local machine and sometimes it works and sometimes it doesn't. Oh, I also worked very slowly.
It would be great If you can adapt the test.

@antoineco
Copy link
Contributor

Will do it today and notify you.

@teresadq
Copy link
Author

OK, ^_^

@antoineco
Copy link
Contributor

antoineco commented Jul 28, 2018

Sorry I don't have enough permissions to push to your branch, so I'll send you a patch per email instead :)

@teresadq
Copy link
Author

@antoineco My email is [email protected]. Thanks

@antoineco
Copy link
Contributor

antoineco commented Jul 28, 2018

Actually no need for email, GitHub can perfectly generate patches: [PATCH] Add e2e test for rewrite-target annotation.

All you have to do is execute
git apply <(curl -sSL https://github.com/antoineco/ingress-nginx/commit/85f6d5a47ff9e15350e92685e122e8215f4ca23d.patch)
then commit the changes.

@teresadq
Copy link
Author

OK, I will study the code these days.

@teresadq teresadq closed this Jul 30, 2018
@teresadq teresadq deleted the bugfix-2799 branch July 30, 2018 09:10
@teresadq teresadq restored the bugfix-2799 branch July 30, 2018 09:24
@teresadq teresadq reopened this Jul 30, 2018
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 30, 2018
@antoineco
Copy link
Contributor

@dongqi1990 I'm re-running e2e tests.

@teresadq
Copy link
Author

teresadq commented Aug 3, 2018

@antoineco I'm curious that the same code sometimes goes through the e2e test and sometimes doesn't. Why?

@antoineco
Copy link
Contributor

Mostly the randomness and instability of public CI environments, most of the time it's just a timing issue. If the same test fails often we try to mitigate timing issues with extra wait conditions, etc. But usually it's pretty stable.

@antoineco
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: antoineco, dongqi1990

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 3, 2018
@k8s-ci-robot k8s-ci-robot merged commit 23ce9b5 into kubernetes:master Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

location is case insensitive but rewrite-target isn't
5 participants