forked from orioledb/orioledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheviction_bgwriter_test.py
67 lines (54 loc) · 1.7 KB
/
eviction_bgwriter_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
# coding: utf-8
import unittest
from .base_test import BaseTest
class EvictionBGWriterTest(BaseTest):
def test_eviction_multiple_bgwriters(self):
node = self.node
node.append_conf(
'postgresql.conf', "orioledb.main_buffers = 8MB\n"
"orioledb.bgwriter_num_workers = 2\n")
node.start()
node.safe_psql(
'postgres', "CREATE EXTENSION IF NOT EXISTS orioledb;\n"
"CREATE TABLE o_eviction (\n"
" key integer NOT NULL,\n"
" val integer NOT NULL,\n"
" PRIMARY KEY(key)\n"
") USING orioledb;\n\n")
n = 200000
node.safe_psql(
'postgres', "INSERT INTO o_eviction\n"
" (SELECT id, %s - id FROM generate_series(%s, %s, 1) id);\n" %
(str(n), str(1), str(n)))
node.stop()
node.start()
self.assertEqual(
node.execute("SELECT COUNT(*) FROM o_eviction;")[0][0], 200000)
node.stop()
def test_eviction_bgwriter_invalidation(self):
node = self.node
node.append_conf('postgresql.conf', "orioledb.main_buffers = 8MB\n")
node.start()
node.safe_psql(
'postgres', "CREATE EXTENSION IF NOT EXISTS orioledb;\n"
"CREATE TABLE o_eviction (\n"
" key integer NOT NULL,\n"
" val integer NOT NULL,\n"
" PRIMARY KEY(key)\n"
") USING orioledb;\n\n")
n = 200000
for i in range(1, 100):
node.safe_psql(
'postgres', "CREATE TABLE o_tmp (\n"
" key integer NOT NULL,\n"
" PRIMARY KEY(key)\n"
") USING orioledb;\n")
node.safe_psql("DROP TABLE o_tmp;")
node.safe_psql(
'postgres', "INSERT INTO o_eviction\n"
" (SELECT id, %s - id FROM generate_series(%s, %s, 1) id);\n" %
(str(n), str(1), str(n)))
node.stop()
if __name__ == "__main__":
unittest.main()