Skip to content

Commit e2867f0

Browse files
committed
add rebuild option to dockerfile
1 parent d2b6c30 commit e2867f0

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

contrib/mmts/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ USER postgres
3131
ENV CFLAGS -O0
3232
WORKDIR /pg
3333

34+
ENV REBUILD false
35+
3436
RUN cd /pg && \
3537
git clone https://github.com/postgrespro/postgres_cluster.git --depth 1 && \
3638
cd /pg/postgres_cluster && \
@@ -40,9 +42,6 @@ RUN cd /pg && \
4042
ENV PATH /pg/install/bin:$PATH
4143
ENV PGDATA /pg/data
4244

43-
44-
# Here we can insert some ENV var to invalidate subsequent layers
45-
4645
RUN cd /pg/postgres_cluster/contrib/raftable && make install
4746

4847
RUN mkdir /pg/mmts

contrib/mmts/tests2/lib/bank_client.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,41 +67,65 @@ def print_error(self, arg, comment=''):
6767

6868
def check_total(self):
6969
conn, cur = self.connect()
70+
i = 0
7071

7172
while self.run.value:
73+
i += 1
74+
7275
event_id = self.history.register_start('total')
7376

77+
if not conn.closed:
78+
try :
79+
conn = psycopg2.connect(self.connstr)
80+
cur = conn.cursor()
81+
except :
82+
self.history.register_finish(event_id, 'CantConnect')
83+
next
84+
85+
amount = 1
86+
from_uid = random.randrange(1, self.accounts + 1)
87+
to_uid = random.randrange(1, self.accounts + 1)
88+
7489
try:
7590
cur.execute('select sum(amount) from bank_test')
7691
res = cur.fetchone()
7792
if res[0] != 0:
7893
print("Isolation error, total = %d" % (res[0],))
7994
raise BaseException
95+
except BaseException:
96+
raise BaseException
8097
except psycopg2.InterfaceError:
81-
conn, cur = self.connect(reconnect=True)
82-
except:
83-
self.print_error(sys.exc_info(),'3')
84-
self.history.register_finish(event_id, 'rollback')
85-
else:
98+
self.history.register_finish(event_id, 'InterfaceError')
99+
except :
100+
self.history.register_finish(event_id, 'OtherError')
101+
else :
86102
self.history.register_finish(event_id, 'commit')
87103

88104
cur.close()
89105
conn.close()
90106

91107
def transfer_money(self):
92-
#conn = psycopg2.connect(self.connstr)
93-
#cur = conn.cursor()
94108
conn, cur = self.connect()
95109

96110
i = 0
111+
97112
while self.run.value:
98113
i += 1
114+
115+
event_id = self.history.register_start('transfer')
116+
117+
if not conn.closed:
118+
try :
119+
conn = psycopg2.connect(self.connstr)
120+
cur = conn.cursor()
121+
except :
122+
self.history.register_finish(event_id, 'CantConnect')
123+
next
124+
99125
amount = 1
100126
from_uid = random.randrange(1, self.accounts + 1)
101127
to_uid = random.randrange(1, self.accounts + 1)
102128

103-
event_id = self.history.register_start('transfer')
104-
105129
try:
106130
cur.execute('''update bank_test
107131
set amount = amount - %s
@@ -111,14 +135,13 @@ def transfer_money(self):
111135
set amount = amount + %s
112136
where uid = %s''',
113137
(amount, to_uid))
114-
115138
conn.commit()
139+
116140
except psycopg2.InterfaceError:
117-
conn, cur = self.connect(reconnect=True)
118-
except:
119-
self.print_error(sys.exc_info(),'1')
120-
self.history.register_finish(event_id, 'rollback')
121-
else:
141+
self.history.register_finish(event_id, 'InterfaceError')
142+
except :
143+
self.history.register_finish(event_id, 'OtherError')
144+
else :
122145
self.history.register_finish(event_id, 'commit')
123146

124147
cur.close()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy