|
90 | 90 |
|
91 | 91 | change_attribute/1, |
92 | 92 |
|
93 | | - otp_6278/1, otp_10131/1, otp_16768/1, otp_16809/1]). |
| 93 | + otp_6278/1, otp_10131/1, otp_16768/1, otp_16809/1, |
| 94 | + |
| 95 | + decrease_size_with_chunk_step/1]). |
94 | 96 |
|
95 | 97 | -export([head_fun/1, hf/0, hf_bin/0, lserv/1, |
96 | 98 | measure/0, init_m/1, xx/0]). |
@@ -167,7 +169,7 @@ groups() -> |
167 | 169 | {change_size, [], |
168 | 170 | [change_size_before, change_size_during, |
169 | 171 | change_size_after, default_size, change_size2, |
170 | | - change_size_truncate]}]. |
| 172 | + change_size_truncate, decrease_size_with_chunk_step]}]. |
171 | 173 |
|
172 | 174 | init_per_suite(Config) -> |
173 | 175 | Config. |
@@ -4419,6 +4421,32 @@ otp_16809(Conf) when is_list(Conf) -> |
4419 | 4421 | HeadFunc2 = info(Log, head, undef), |
4420 | 4422 | ok = disk_log:close(Log). |
4421 | 4423 |
|
| 4424 | +decrease_size_with_chunk_step(Conf) when is_list(Conf) -> |
| 4425 | + Dir = ?privdir(Conf), |
| 4426 | + Log = decrease_size_with_chunk_step, |
| 4427 | + File = filename:join(Dir, lists:concat([Log, ".LOG"])), |
| 4428 | + {ok, Log} = disk_log:open([{size, {50, 3}}, {name, Log}, {type, wrap}, |
| 4429 | + {file, File}, {notify, true}]), |
| 4430 | + eof = disk_log:chunk(Log, start, 1), |
| 4431 | + {error, end_of_log} = disk_log:chunk_step(Log, start, 1), |
| 4432 | + ok = disk_log:log_terms(Log, [1, 2, 3, 4, 5, 6, 7, 8, 9]), |
| 4433 | + ok = disk_log:close(Log), |
| 4434 | + {ok, Log} = disk_log:open([{name, Log}, {type, wrap}, {file, File}, |
| 4435 | + {notify, true}]), |
| 4436 | + %% Decrease maximum number of files from 3 to 2. |
| 4437 | + ok = disk_log:change_size(Log, {50, 2}), |
| 4438 | + %% The exception error of rem/2 operator should not occur in here. |
| 4439 | + {ok, Cont} = disk_log:chunk_step(Log, start, 2), |
| 4440 | + %% Verify that chunk_step has stepped to old max file (3) |
| 4441 | + {_, [7, 8, 9]} = disk_log:chunk(Log, Cont), |
| 4442 | + %% Continue to append the items to the log in order to make sure it can work |
| 4443 | + %% as normal. |
| 4444 | + ok = disk_log:log_terms(Log, [9, 8, 7, 6, 5, 4, 3, 2, 1]), |
| 4445 | + %% Verify that log files were decreased to 2 after wrapping |
| 4446 | + [6, 5, 4, 3, 2, 1] = get_all_terms(Log), |
| 4447 | + ok = disk_log:close(Log), |
| 4448 | + del(File, 2). |
| 4449 | + |
4422 | 4450 | mark(FileName, What) -> |
4423 | 4451 | {ok,Fd} = file:open(FileName, [raw, binary, read, write]), |
4424 | 4452 | {ok,_} = file:position(Fd, 4), |
|
0 commit comments