drogonframework / drogonframework/drogon

failing "if-modified-since" test on overloaded systems

Open
#1,491 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Describe the bug**
There is currently a [test for the "if-modified-since" header](https://github.com/drogonframework/drogon/blob/3adf168a87e7ba3f2e1ba5e8a327f7f5494e8ef4/lib/tests/integration_test/client/main.cc#L573-L585) which can fail when the system is running slowly. The [current implementation](https://github.com/drogonframework/drogon/blob/3adf168a87e7ba3f2e1ba5e8a327f7f5494e8ef4/lib/src/StaticFileRouter.cc#L454) for static files will only return `k304NotModified` if the file was last modified within one second of the value of the "if-modified-since" header. If the system is under strain, it is possible for this test to fail because the file was modified more than one second ago.

**To Reproduce**
This can be reproduced by applying the following patch (to artificially make the test slower) and then running the test suite
```
diff --git a/lib/tests/integration_test/client/main.cc b/lib/tests/integration_test/client/main.cc
index d8396a4..18e0737 100644
--- a/lib/tests/integration_test/client/main.cc
+++ b/lib/tests/integration_test/client/main.cc
@@ -573,6 +573,7 @@ void doTest(const HttpClientPtr &client, std::shared_ptr TEST_CTX)
auto &lastModified = resp->getHeader("last-modified");
// LOG_DEBUG << lastModified;
// Test 'Not Modified'
+ sleep(5);
auto req = HttpRequest::newHttpRequest();
req->setMethod(drogon::Get);
req->setPath("/drogon.jpg");
```

**Expected behavior**
the test should pass regardless of the current system load

**Desktop (please complete the following information):**
- OS: x86_64 linux
- Browser N/A
- Version 1.8.3

**Additional context**
this test fails on nixpkgs automated build infrastructure NixOS/nixpkgs#212206

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.