Fix problem with race condition of forked ostf

When there is a more then one check in ostf it fails
and only one process works. Other forks are dead because
they can not fetch information from database.
Eventually information is flushed in database, but only
after forks are dead.
Sleep helped to wait for information to propagate to
other processes. This fix flush and commit information
to database so it is available for other forks.

Change-Id: Ib8540309dee00f7f0ea7cd65215c4872c4147b6f
Closes-bug: #1520218
This commit is contained in:
Alexandr Kostrikov 2015-12-01 18:16:19 +03:00 committed by Alexandr Kostrikov
parent 23b7ae2a1a
commit 415efd1d09
2 changed files with 7 additions and 6 deletions

View File

@ -16,7 +16,6 @@ import fcntl
import logging
import os
import signal
import time
try:
from oslo.config import cfg
@ -80,11 +79,6 @@ class NoseDriver(object):
raise InterruptTestRunException()
signal.signal(signal.SIGUSR1, raise_exception_handler)
# FIXME(dteselkin): add some sleep to allow process to
# initialize db before selecting data
# LP#1522941
time.sleep(1)
with engine.contexted_session(dbpath) as session:
testrun = session.query(models.TestRun)\
.filter_by(id=test_run_id)\

View File

@ -309,6 +309,13 @@ class TestRun(BASE):
new_test = test.copy_test(test_run, predefined_tests)
session.add(new_test)
test_run.tests.append(new_test)
# NOTE(akostrikov) Seems there is a problem with transaction
# isolation, so we need not only to flush, but also to commit.
# We fork and then in forks we flush sql items. But it seems that
# it happens in transaction so we are not getting in other
# processes add results. So I force transaction commit to provide
# changes to all forks os OSTF.
session.commit()
session.flush()
return test_run