-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix b3 header #2519
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 b3 header #2519
Conversation
There were couple of hacks in test/elixir/lib/couch.ex We've got changes needed to remove them into httpotion 3.1.3. The changes were introduced in: - valpackett/httpotion#118 - valpackett/httpotion#130
| defp create_admin(user_name, password) do | ||
| hashed = String.to_charlist(:couch_passwords.hash_admin_password(password)) | ||
| :config.set('admins', String.to_charlist(user_name), hashed, false) | ||
| end |
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.
It seems like the create_admin function along with some of the other function below would be useful to have in the shared Couch library. Any particular reason to not put these functions into the couch.ex module?
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.
Few concerns:
- I tried that before [1] and [2]
- the complain was: we are developing our own framework which people need to learn.
- Adding
create_admintoCouchexibit a chicken and egg problem.Couchimplements HTTP interface. We cannot use HTTP interface without adding admin first. In context of eunit tests we always cheated and created admin via config manipulation. - We could consider
create_adminan exception and still add it toCouchinspite of it not being HTTP based interface. However it will introduce a confusion. People useCouchmodule from elixir integration tests and the function wouldn't work in the context of an integration test.
When I was writing this test I considered using Step.User.new(:admin, roles: [:server_admin]). However since pluguble adapters [1] didn't make it to the framework and [2] doesn't have fabric2 support, so I had to do it differently. I followed the advise of the committers who believe that DRY is bad for tests and they should be as self contained as possible.
[1]: #2036 - plugable adaptors based approach
[2]: #2039 - fabric only interface
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.
Ahhhh ok, thanks for the detailed explanation @iilyak 👍. It's outside the scope of this PR, but I wonder if it would make sense to add a tag like @tag :with_admin like we've done with dbs and what not [1], to inject an admin user context into the test and then we can abstract away whether the admin user was created through config or the http interface. As for framework vs anti DRY, initially with the Elixir suite we tried to avoid making a heavy framework, which I think is worthwhile, but at the same time there's common activities which should be easy to take care of, like creating dbs/docs/users/ddocs/etc.
jaydoane
left a comment
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.
$ make exunit apps=chttpd
...
* test Open Tracing should return success with combined b3 header (276.6ms)
Finished in 3.6 seconds
1 test, 0 failures
|
Thanks for this fix Ilya |
Overview
The B3 header parsing introduced in #2309 is broken. When b3 header is set the chttpd request is crashing with the following message:
The reason for the crash is obvious. The
binary:split/3is used in the place where we have string as an argument. According to the code in mochiweb_headers.erl the headers are always strings. This PR switches frombinary:split/3tostring:split/3. In order to make sure the change is working as expected the test is written. There was a need to adjust some testing plumbing to make test pass. This adjustment was done in the same PR since it is the very first test of this kind and testing adjustment in separate PR would be quite tricky. The adjustment to test plumbing consists of two changes:Testing recommendations
make exunit apps=chttpd- the test should pass3b9f04db97locally and run test again - the test should timeoutRelated Issues or Pull Requests
Checklist
rel/overlay/etc/default.ini