diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2019-12-04 18:53:37 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2019-12-05 10:47:37 +0100 |
| commit | 28a41d37061b9c01f2f8e295d2d963cb1a07f36b (patch) | |
| tree | 6f3f2d327fabb4f185ee93ff8b8070501097beff | |
| parent | cc98cb3c79748cb623310f1500285d2a3d6a81d9 (diff) | |
| download | rabbitmq-server-git-28a41d37061b9c01f2f8e295d2d963cb1a07f36b.tar.gz | |
unit_inbroker_non_parallel_SUITE: Skip log file test if dir writable
If the supposedly non-writable directory is writable (e.g. we are
running the testsuite on Windows as Administrator), we skip this test.
On Unix, we now use `/` as the non-writable directory because
`/var/empty` may not exist. For instance, this is the case on Debian
Stretch AWS EC2 image.
| -rw-r--r-- | test/unit_inbroker_non_parallel_SUITE.erl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/test/unit_inbroker_non_parallel_SUITE.erl b/test/unit_inbroker_non_parallel_SUITE.erl index 69b0efc8fe..120a7fdbd9 100644 --- a/test/unit_inbroker_non_parallel_SUITE.erl +++ b/test/unit_inbroker_non_parallel_SUITE.erl @@ -462,20 +462,31 @@ log_file_initialised_during_startup1(_Config) -> log_file_fails_to_initialise_during_startup(Config) -> - passed = rabbit_ct_broker_helpers:rpc(Config, 0, - ?MODULE, log_file_fails_to_initialise_during_startup1, [Config]). + NonWritableDir = case os:type() of + {win32, _} -> "C:/Windows"; + _ -> "/" + end, + case file:open(filename:join(NonWritableDir, "test.log"), [write]) of + {error, eacces} -> + passed = rabbit_ct_broker_helpers:rpc( + Config, 0, + ?MODULE, log_file_fails_to_initialise_during_startup1, + [Config, NonWritableDir]); + {ok, Fd} -> + %% If the supposedly non-writable directory is writable + %% (e.g. we are running the testsuite on Windows as + %% Administrator), we skip this test. + file:close(Fd), + {skip, "Supposedly non-writable directory is writable"} + end. -log_file_fails_to_initialise_during_startup1(_Config) -> +log_file_fails_to_initialise_during_startup1(_Config, NonWritableDir) -> [LogFile|_] = rabbit:log_locations(), %% start application with logging to directory with no %% write permissions ok = rabbit:stop(), - NonWritableDir = case os:type() of - {win32, _} -> "C:/Windows"; - _ -> "/var/empty" - end, Run1 = fun() -> NoPermission1 = filename:join(NonWritableDir, "test.log"), delete_file(NoPermission1), @@ -497,7 +508,9 @@ log_file_fails_to_initialise_during_startup1(_Config) -> %% start application with logging to a subdirectory which %% parent directory has no write permissions - NoPermission2 = filename:join(NonWritableDir, "non-existent/test.log"), + NoPermission2 = filename:join([NonWritableDir, + "non-existent", + "test.log"]), Run2 = fun() -> delete_file(NoPermission2), |
