Debian Codegraph @

dirsrvtests/tests/suites/lib389/timeout_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2023 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8 #
9 import logging
10 import pytest
11 import os
12 import time
13 from lib389._constants import *
14 from test389.topologies import topology_st as topo, set_timeout
15
16 logging.basicConfig(format='%(asctime)s %(message)s', force=True)
17 log = logging.getLogger(__name__)
18 log.setLevel(logging.DEBUG)
19 # create console handler with a higher log level
20 ch = logging.StreamHandler()
21 ch.setLevel(logging.DEBUG)
22 # create formatter and add it to the handlers
23 formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
24 ch.setFormatter(formatter)
25 # add the handlers to logger
26 log.addHandler(ch)
27
28 TEST_TIMEOUT = 150
29
30 @pytest.fixture(autouse=True, scope="module")
31 def init_timeout():
32 set_timeout(TEST_TIMEOUT)
33
34 def test_timeout(topo):
35 """Specify a test case purpose or name here
36
37 :id: 4a2917d2-ad4c-44a7-aa5f-daad26d1d36e
38 :setup: Standalone Instance
39 :steps:
40 1. Fill in test case steps here
41 2. And indent them like this (RST format requirement)
42 :expectedresults:
43 1. Fill in the result that is expected
44 2. For each test step
45 """
46
47 with pytest.raises(TimeoutError):
48 log.info("Start waiting %d seconds" % TEST_TIMEOUT )
49 time.sleep(TEST_TIMEOUT)
50 log.info("End waiting")
51 for inst in topo:
52 assert inst.status() is False
53
54
55 if __name__ == '__main__':
56 # Run isolated
57 # -s for DEBUG mode
58 CURRENT_FILE = os.path.realpath(__file__)
59 pytest.main(["-s", CURRENT_FILE])
60