Skip to content

Programmable HTTP mock server#529

Merged
xerial merged 1 commit intowvlet:masterfrom
takezoe:programmable-http-server
Jul 3, 2019
Merged

Programmable HTTP mock server#529
xerial merged 1 commit intowvlet:masterfrom
takezoe:programmable-http-server

Conversation

@takezoe
Copy link
Copy Markdown
Member

@takezoe takezoe commented Jul 2, 2019

No description provided.

@xerial xerial mentioned this pull request Jul 2, 2019
66 tasks
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 2, 2019

Codecov Report

Merging #529 into master will increase coverage by 0.02%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #529      +/-   ##
==========================================
+ Coverage   83.69%   83.72%   +0.02%     
==========================================
  Files         216      216              
  Lines        7992     8000       +8     
  Branches      583      578       -5     
==========================================
+ Hits         6689     6698       +9     
+ Misses       1303     1302       -1
Impacted Files Coverage Δ
...wvlet/airframe/http/recorder/HttpRecordStore.scala 97.61% <100%> (+0.05%) ⬆️
...la/wvlet/airframe/http/recorder/HttpRecorder.scala 96.55% <90.9%> (+1.09%) ⬆️
...main/scala/wvlet/airframe/http/ServerAddress.scala 92% <0%> (+4%) ⬆️

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 4365522...02542fb. Read the comment docs.

@takezoe takezoe force-pushed the programmable-http-server branch from ec95080 to 31f2492 Compare July 2, 2019 15:30
}
prefix.hashCode * 13 + headerHash
prefix.hashCode * 13 + headerHash
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Computing hash value hasn't worked if HeaderMap is empty.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch!

override def requestHash(request: Request): Int = {
val content = request.getContentString()
s"${request.method.toString()}:${recorderConfig.destAddress.hostAndPort}${request.uri}:${content.hashCode}".hashCode
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's difficult to program exact same headers. I think matching by method, address, uri and content is good enough in the programmable HTTP mock server.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok. Let's add a customization entry point to HttpRecordStore later to add user-defined pattern matching rules.

No change is required for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My idea is adding a method like:

HttpRecordStore.withRequestMatcher(matcher:PartialFunction[Request, Response])

@takezoe takezoe force-pushed the programmable-http-server branch from 31f2492 to 55508ed Compare July 2, 2019 16:17
@takezoe takezoe changed the title [WIP] Programmable HTTP mock server Programmable HTTP mock server Jul 2, 2019
@takezoe takezoe force-pushed the programmable-http-server branch from 55508ed to 02542fb Compare July 2, 2019 23:31
@takezoe takezoe requested a review from xerial July 2, 2019 23:31
Copy link
Copy Markdown
Member

@xerial xerial left a comment

Choose a reason for hiding this comment

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

OK. Let's add and try this :)

@xerial xerial merged commit f33cdba into wvlet:master Jul 3, 2019
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.

2 participants