Skip to content

ragdata-vault/sleepy-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Issues πŸ”Έ Documentation πŸ”Έ Releases

A Sleepy Software Testing Utility

GitHub issues Last Commit MIT

Elapsed Project Time

wakatime

If you like this repository, please give it a ⭐ (it really does help)

GitHub repository stars

The Sleepy Server is a simple software testing utility. The server will sleep for the period specified in the incoming request before it responds.

The only API method takes a single parameter:

http(s)://sleepy.server.org/:sleepValue

Where :sleepValue determines the period that the server will wait before sending a response.

The length of the delay is calculated as the :sleepValue multiplied by the valueMultiplier environment variable (which defaults to 1000 - and as such, we can say that the length of the delay is counted in milliseconds)

Docker Image

Use the 'standard' method to launch the Docker Image from the root directory of the project:

docker build -t sleepy:test .

Examples

Example #1

With a :sleepValue of 5 (and the default multiplyer = 1000)

$ date; time http http://localhost:3000/5 -b; date
Wed Nov 16 09:02:02 CET 2022
Woke up after 5 second(s) of sleep!
...  0.35s user 0.15s system 8% cpu 5.655 total
Wed Nov 16 09:02:08 CET 2022

In your terminal window, the scenario might play out like this:

$ docker run --rm -p 3000:3000 -d sleepy:test
$ docker logs -tf agitated_elemental
2022-11-16T08:00:23.621848495Z Sleeping server listening on port 3000
2022-11-16T08:02:03.494774343Z Going to sleep for 5 second(s)!
2022-11-16T08:02:08.498342553Z Wake up! 5 second(s) passed.

Example #2

Simultaneous Requests:

$ date; for I in $(seq 5 -2 1); do \
		((http GET http://localhost:3000/$I -b | cat - && echo -n ' -- ' && date) &) \
	done
		
Wed Nov 16 09:03:47 CET 2022
Woke up after 1 second(s) of sleep! -- Wed Nov 16 09:03:48 CET 2022
Woke up after 3 second(s) of sleep! -- Wed Nov 16 09:03:50 CET 2022
Woke up after 5 second(s) of sleep! -- Wed Nov 16 09:03:52 CET 2022

And in the server logs:

2022-11-16T08:03:47.917399749Z Going to sleep for 5 second(s)!
2022-11-16T08:03:47.923730533Z Going to sleep for 1 second(s)!
2022-11-16T08:03:47.924537943Z Going to sleep for 3 second(s)!
2022-11-16T08:03:48.925443668Z Wake up! 1 second(s) passed.
2022-11-16T08:03:50.925969532Z Wake up! 3 second(s) passed.
2022-11-16T08:03:52.918711537Z Wake up! 5 second(s) passed.

Configuration (Environment Variables)

  • port - the port on the server will be listening on
  • valueMultiplier - the multiplier of :sleepValue which is used to calculate the length of the delay before the server responds. Leaving this value set to the default of 1000 makes :sleepValue roughly equal to a number of seconds.

Project Resources:

Community Resources

^ Top

❀️ Project Supporters

JetBrains

JetBrains very generously provide me with a free license for their products every month, and you can get one too if you're working on a public, open-source project! I've used JetBrains' IDEs for many years now, and was more than happy to pay for a license every year back when I was working in the corporate sector. Absolutely my first choice in IDEs!

If sponsorship isn't right for you, but you have found my work to be useful in some way,
would you please consider buying me a coffee to help keep me going?

Buy Me A Coffee

^ Top

^ Top

πŸ” Security

While I always good security practices, 100% security can never be guaranteed in any software package. The Sleepy Server is provided AS IS, and without warranty. You can find more details in the LICENSE file included with this repository.

If you discover any issue regarding the security of this project, please disclose that information responsibly by sending a security advisory. PLEASE DO NOT CREATE AN ISSUE OR DISCUSSION TOPIC. You can read more about this project's security policies HERE

^ Top

This project incorporates ideas and / or code crafted by the following talented individuals:

"We see much further, and reach much higher,
only because we stand upon the shoulders of giants"

^ Top

βš–οΈ License

MIT

Copyright Β© 2023 Darren (Ragdata) Poulton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

^ Top

πŸ“– Resources

^ Top

If you like this repository, please give it a ⭐ (it really does help)

GitHub repository stars

Visitors Ragdata