Comments (9)
Ignore my silly concern about 2 runs - 2 tests, 2 runs! :-)
from oatpp.
Leonid,
Thanks again for the feedback.
- I have updated to
0.19.6
and started usingoatpp::base::Environment
for logging. - I think using
std::shared_ptr
should prevent any memory leaks. - Will definitely consider caching it the load requires it.
Thanks a lot.
from oatpp.
Hello @vinkaga ,
Please find the PR vinkaga/oatpp-test#1
I added some comments to the steps of the test and its structure in the code.
The main problem was that config components were deleted before Runner object tried to inject them.
Apart from that you may find some additional "complicated" code for proper server stoppage and stoppage of async executor. Most of this complexity is because of the "real" port usage and difference in behavior of Linux/BSD api calls, read/write/close.
Which you may avoid by using oatpp virtual networking for test purposes.
You may also find some useful info here Testing oatpp applications
Note
You are using oatpp Async API for you controller. Developing using Async API may be pretty complicated when it comes to business logic / consuming other services / synchronization.
TIP: You may opt to use oatpp simple API (with multi threaded server) instead, which is much more "user friendly".
Async API - is needed for cases where you have to handle more than 1K simultaneous connections.
If you don't expect such load on you service - Simple API is the choice
Please let me know in case of any questions.
Best Regards,
Leonid
from oatpp.
Closing this.
@vinkaga please let me know if there are still questions left.
from oatpp.
I switched to using sync API. In order to remove boilerplate from the tests, I modified TestRunner and ControllerTest.
Is this a reasonable approach?
from oatpp.
Hello @vinkaga ,
I have reviewed the code. Looks good to me.
Comments:
-
Here https://github.com/vinkaga/oatpp-test/blob/master/src/Components.hpp#L37 you also have to switch to "sync"
HttpConnectionHandler
. -
And you don't need this any more https://github.com/vinkaga/oatpp-test/blob/master/test/TestComponents.hpp#L16
Other from that looks great, even that you have defined your own TestRunner. But why not.
Regards,
Leonid
from oatpp.
Hello Leonid,
Would take a minute to look over the latest iteration of the my oatpp sample/test at https://github.com/vinkaga/oatpp-test? Here is the list of changes since the last version:
- Removed Environment usage and moved components into Server and TestClient objects. For me, it's easier for conceptual visualization and also reduces test boilerplate but does reduce dependency injectability.
- Added static content handler from your media example.
Additionally, not sure why, I get server running/stopped message twice when I run the test.
$ ./oatppex_test
Server Running on port 8000
Server Stopped
Server Running on port 8000
Server Stopped
===============================================================================
All tests passed (4 assertions in 2 test cases)
Thanks,
Vinay
from oatpp.
Hello @vinkaga ,
Would take a minute to look over the latest iteration of the my oatpp sample/test
Currently I am not able to review your code. But I will do it for sure.
Most probably I will be available tomorrow or the day after tomorrow.
Please feel free to put all the questions you have in the issues,- I will answer them all once I am available.
Regards,
Leonid
from oatpp.
Hello @vinkaga ,
I have reviewed the code. Everything looks good!
Some comments:
- Please move to oatpp version
0.19.6
. Project is in alpha so its important to be on a latest version. - It is recommended to use
oatpp::base::Environment
at least in order to make calls toOATPP_LOGD
D/V/I/W/E to work and see oatpp system logs. You may also benefit from oatpp object counting in the tests to detect memory-leaks. - As you are building static server, you may want to think of a caching mechanism in order to reduce load on a hard-drive.
Regards,
Leonid
from oatpp.
Related Issues (20)
- Regarding oatpp::async::CoroutineWithResult HOT 9
- How to add default values to the QUERY parameters of an ENDPOINT?
- Enhance Deserializer's "Error. Unknown field"
- How can I use OATPP to handle web browser request download file. HOT 2
- Memory leak in Object mapping HOT 1
- Deserialize json when not include required field only gives error when the field is specified as null
- [Question] readBodyIntoDTO when there's a list in the body
- API question
- how to make dynamic sql use oatpp-sqlite HOT 1
- LazyStringMapTemplate::get returns Nullptr wich is not in oatpp.io Documentation
- Please add support for CMake 3.16
- Cannot test if required integer query parameter is empty
- [Question] Is it possible during compilation to write out the generated oas-3.0.0.json file?
- May memory leak
- How should I make my process send requests to the target when using OATPP HOT 4
- Stack corruption issue in ConnectionProvider.cpp
- Can not build project successfully
- Is it possible make oatpp::network::tcp::client::ConnectionProvider support bind client IP?
- specific async pattern implementation query HOT 4
- io_uring support request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oatpp.