Files
scylladb/test/boost/generic_server_test.cc
Laszlo Ersek 16321fc243 test/generic_server: add test case
Check whether we can stop a generic server without first asking it to
listen.

The test fails currently; the failure mode is a hang, which triggers the 5
minute timeout set in the test:

> unknown location(0): fatal error: in "stop_without_listening":
> seastar::timed_out_error: timedout
> seastar/src/testing/seastar_test.cc(43): last checkpoint
> test/boost/generic_server_test.cc(34): Leaving test case
> "stop_without_listening"; testing time: 300097447us

Backport notes for 6.1:

- Replace

    #include "utils/assert.hh"
    SCYLLA_ASSERT(false);

  with

    #include <cassert>
    assert(false);

  due to 6.1 lacking commit aa1270a00c ("treewide: change assert() to
  SCYLLA_ASSERT()", 2024-08-05). The header file "utils/assert.hh"
  wouldn't be difficult to backport, but separating it from the treewide
  changes in commit aa1270a00c might not be the best idea.

Signed-off-by: Laszlo Ersek <laszlo.ersek@scylladb.com>
(cherry picked from commit dbc0ca6354)
2024-08-30 16:17:44 +02:00

38 lines
885 B
C++

/*
* Copyright (C) 2024-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <cassert>
#include <chrono>
#include <seastar/core/lowres_clock.hh>
#include <seastar/core/with_timeout.hh>
#include <seastar/testing/test_case.hh>
#include <seastar/util/log.hh>
#include "generic_server.hh"
using namespace generic_server;
using namespace logging;
using namespace seastar;
using namespace std::literals::chrono_literals;
static logger test_logger("test_server");
class test_server : public server {
public:
test_server() : server("test_server", test_logger) {};
protected:
[[noreturn]] shared_ptr<connection> make_connection(socket_address, connected_socket&&, socket_address) {
assert(false);
}
};
SEASTAR_TEST_CASE(stop_without_listening) {
test_server srv;
co_await with_timeout(lowres_clock::now() + 5min, srv.stop());
}