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

proxy: add response API tests in proxyunits.t #1035

Closed
wants to merge 1 commit into from

Conversation

feihu-stripe
Copy link
Contributor

@feihu-stripe feihu-stripe commented May 10, 2023

No description provided.

@@ -251,6 +252,8 @@ static int _mcmc_parse_response(mcmc_ctx_t *ctx, mcmc_resp_t *r) {
} else {
r->vlen_read = buffer_remain;
}
// remove vsize and any leading space from response length.
l -= (n - cur) / sizeof(char);
Copy link
Member

Choose a reason for hiding this comment

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

sizeof(char) is defined as 1 in the C spec. can skip the division.

@dormando
Copy link
Member

So, mcmc lives here: https://github.com/dormando/mcmc - with its own unit tests. I can port this over and add the tests but if you want to try go ahead.

when I make changes to mcmc I do them in order:

  • change upstream
  • individual commit updating vendor/mcmc
  • individual commit utilizing the updated mcmc

it lets me see historically when vendor stuff changes specifically.

@feihu-stripe
Copy link
Contributor Author

Sure I can give it a try.

@dormando
Copy link
Member

might be nice in the meantime if you separate out the working tests so I can upstream those. you can leave the broken test in with a skip marker and repair it afterward.

@feihu-stripe
Copy link
Contributor Author

will do

@feihu-stripe feihu-stripe force-pushed the feihu/proxyunits3 branch 2 times, most recently from eccb164 to dae5bf4 Compare May 12, 2023 13:30
@feihu-stripe feihu-stripe changed the title proxy: fix bugs with response:line() and added tests proxy: add response API tests in proxyunits.t May 12, 2023
@feihu-stripe
Copy link
Contributor Author

mcmc fix moved to dormando/mcmc#3

PR should now be mergable.

t/proxyunits.t Outdated
subtest 'response:hit()' => sub {
# ps_recv must not receive an error
proxy_test(
ps_send => "mg /response/ok\r\n",
Copy link
Member

Choose a reason for hiding this comment

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

double testing ok() instead of hit here.

should also test cases where ok/hit are false work properly.

@dormando
Copy link
Member

I think the rest looks good but kinda groggy and need to think more.

for the hit() and ok() tests there are a few backend conditions which can result in ok(). ideally we test more than one of them.

@feihu-stripe
Copy link
Contributor Author

Added more cases for ok() and hit()

@dormando
Copy link
Member

looks okay I think. I'm going to need to come back after a break for a final review though; if you think you're done feel free to squash it.

@feihu-stripe
Copy link
Contributor Author

looks okay I think. I'm going to need to come back after a break for a final review though; if you think you're done feel free to squash it.

Did what I can think of, but I guess it is never 100%.

Squahsed.

@dormando
Copy link
Member

Thanks. I think it's more important to round this out by ensuring we have mcp.pool two-arg tests now. We should be periodically revisiting the tests and adding layers to it instead of trying to waterfall full scenarios anyway.

@feihu-stripe
Copy link
Contributor Author

we have mcp.pool two-arg tests now

sure will take a look

@dormando
Copy link
Member

there're a bunch of examples commented in t/startfile.lua fwiw.

local key = r:key()
if key == "/response/elapsed" then
local elapsed = res:elapsed()
if elapsed > 100000 then
Copy link
Member

Choose a reason for hiding this comment

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

should probably just check that elapsed is nonzero to avoid flaky test behavior.

@dormando
Copy link
Member

merged it. didn't feel like the comment was a blocker.

@dormando
Copy link
Member

Released in 1.6.21

@dormando dormando closed this Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants