Commit bada5e1a authored by Adrian Reber's avatar Adrian Reber Committed by Andrei Vagin

Fix RPC configuration file test case

The relevant test case test_rpc_with_configuration_file_overwriting_rpc()
was actually designed around the broken behaviour. It was only working
if a previous configuration file (set via environment variable in this
case) and the RPC configuration file have the same name. The test case
which tests that RPC configuration file settings are overwriting direct
RPC settings now makes sure that no other configuration file is set via
the environment variable. If it would be set, the test case would still
succeed, even with the previous patch applied. Which is and which was the
correct behaviour.

So the main reason for this change is to test the more likely use case
that the environment based configuration file and the RPC configuration
file have different names.
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent b1c9e7fa
...@@ -34,10 +34,18 @@ def setup_config_file(content): ...@@ -34,10 +34,18 @@ def setup_config_file(content):
def cleanup_config_file(path): def cleanup_config_file(path):
del os.environ['CRIU_CONFIG_FILE'] if os.environ.get('CRIU_CONFIG_FILE', None) is not None:
del os.environ['CRIU_CONFIG_FILE']
os.unlink(path) os.unlink(path)
def cleanup_output(path):
for f in (does_not_exist, log_file):
f = os.path.join(path, f)
if os.access(f, os.F_OK):
os.unlink(f)
def setup_criu_dump_request(): def setup_criu_dump_request():
# Create criu msg, set it's type to dump request # Create criu msg, set it's type to dump request
# and set dump options. Checkout more options in protobuf/rpc.proto # and set dump options. Checkout more options in protobuf/rpc.proto
...@@ -155,6 +163,9 @@ def test_rpc_with_configuration_file_overwriting_rpc(): ...@@ -155,6 +163,9 @@ def test_rpc_with_configuration_file_overwriting_rpc():
content = 'log-file ' + log + '\n' content = 'log-file ' + log + '\n'
content += 'no-tcp-established\nno-shell-job' content += 'no-tcp-established\nno-shell-job'
path = setup_config_file(content) path = setup_config_file(content)
# Only set the configuration file via RPC;
# not via environment variable
del os.environ['CRIU_CONFIG_FILE']
req = setup_criu_dump_request() req = setup_criu_dump_request()
req.opts.config_file = path req.opts.config_file = path
_, s = setup_swrk() _, s = setup_swrk()
...@@ -169,14 +180,13 @@ parser.add_argument('dir', type = str, help = "Directory where CRIU images shoul ...@@ -169,14 +180,13 @@ parser.add_argument('dir', type = str, help = "Directory where CRIU images shoul
args = vars(parser.parse_args()) args = vars(parser.parse_args())
try: cleanup_output(args['dir'])
# optional cleanup
os.unlink(os.path.join(args['dir'], does_not_exist))
os.unlink(os.path.join(args['dir'], log_file))
except OSError:
pass
test_broken_configuration_file() test_broken_configuration_file()
cleanup_output(args['dir'])
test_rpc_without_configuration_file() test_rpc_without_configuration_file()
cleanup_output(args['dir'])
test_rpc_with_configuration_file() test_rpc_with_configuration_file()
cleanup_output(args['dir'])
test_rpc_with_configuration_file_overwriting_rpc() test_rpc_with_configuration_file_overwriting_rpc()
cleanup_output(args['dir'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment