git/t/helper
Derrick Stolee 2fec604f8d maintenance: add start/stop subcommands
Add new subcommands to 'git maintenance' that start or stop background
maintenance using 'cron', when available. This integration is as simple
as I could make it, barring some implementation complications.

The schedule is laid out as follows:

  0 1-23 * * *   $cmd maintenance run --schedule=hourly
  0 0    * * 1-6 $cmd maintenance run --schedule=daily
  0 0    * * 0   $cmd maintenance run --schedule=weekly

where $cmd is a properly-qualified 'git for-each-repo' execution:

$cmd=$path/git --exec-path=$path for-each-repo --config=maintenance.repo

where $path points to the location of the Git executable running 'git
maintenance start'. This is critical for systems with multiple versions
of Git. Specifically, macOS has a system version at '/usr/bin/git' while
the version that users can install resides at '/usr/local/bin/git'
(symlinked to '/usr/local/libexec/git-core/git'). This will also use
your locally-built version if you build and run this in your development
environment without installing first.

This conditional schedule avoids having cron launch multiple 'git
for-each-repo' commands in parallel. Such parallel commands would likely
lead to the 'hourly' and 'daily' tasks competing over the object
database lock. This could lead to to some tasks never being run! Since
the --schedule=<frequency> argument will run all tasks with _at least_
the given frequency, the daily runs will also run the hourly tasks.
Similarly, the weekly runs will also run the daily and hourly tasks.

The GIT_TEST_CRONTAB environment variable is not intended for users to
edit, but instead as a way to mock the 'crontab [-l]' command. This
variable is set in test-lib.sh to avoid a future test from accidentally
running anything with the cron integration from modifying the user's
schedule. We use GIT_TEST_CRONTAB='test-tool crontab <file>' in our
tests to check how the schedule is modified in 'git maintenance
(start|stop)' commands.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-25 10:59:44 -07:00
..
.gitignore t/helper: ignore only executable files 2019-09-20 11:13:13 -07:00
test-advise.c advice: revamp advise API 2020-03-05 06:15:02 -08:00
test-bloom.c t: make test-bloom initialize repository 2020-07-30 09:16:45 -07:00
test-chmtime.c
test-config.c config: provide access to the current line number 2020-02-10 10:52:10 -08:00
test-crontab.c maintenance: add start/stop subcommands 2020-09-25 10:59:44 -07:00
test-ctype.c
test-date.c test_date.c: remove reference to GIT_TEST_DATE_NOW 2019-09-18 14:15:01 -07:00
test-delta.c
test-dir-iterator.c Merge branch 'mt/dir-iterator-updates' 2019-08-09 10:13:14 -07:00
test-drop-caches.c Sync with 2.17.3 2019-12-06 16:29:15 +01:00
test-dump-cache-tree.c
test-dump-fsmonitor.c fsmonitor: change last update timestamp on the index_state to opaque token 2020-01-13 14:58:43 -08:00
test-dump-split-index.c t/helper/test-dump-split-index: initialize git repository 2020-02-24 09:33:24 -08:00
test-dump-untracked-cache.c
test-example-decorate.c object: convert lookup_unknown_object() to use object_id 2019-06-20 10:06:19 -07:00
test-fake-ssh.c
test-genrandom.c
test-genzeros.c
test-hash-speed.c
test-hash.c
test-hashmap.c hashmap_entry: remove first member requirement from docs 2019-10-07 10:20:12 +09:00
test-index-version.c
test-json-writer.c
test-lazy-init-name-hash.c OFFSETOF_VAR macro to simplify hashmap iterators 2019-10-07 10:20:11 +09:00
test-line-buffer.c
test-match-trees.c match-trees.c: remove the_repo from shift_tree*() 2019-06-27 12:45:17 -07:00
test-mergesort.c
test-mktemp.c
test-oid-array.c t/helper: initialize the repository for test-sha1-array 2020-06-19 14:04:08 -07:00
test-oidmap.c test-oidmap: remove 'add' subcommand 2019-07-01 10:26:28 -07:00
test-online-cpus.c
test-parse-options.c parse-options: add testcases for OPT_CMDMODE() 2020-02-20 13:20:40 -08:00
test-parse-pathspec-file.c test-parse-pathspec-file.c: s/0/NULL/ for pointer type 2020-04-27 11:21:12 -07:00
test-path-utils.c real_path: remove unsafe API 2020-03-10 11:41:40 -07:00
test-pkt-line.c pkt-line: define PACKET_READ_RESPONSE_END 2020-05-24 16:26:00 -07:00
test-prio-queue.c
test-progress.c progress.c: silence cgcc suggestion about internal linkage 2020-04-27 11:21:28 -07:00
test-reach.c Merge branch 'cb/is-descendant-of' 2020-07-06 22:09:16 -07:00
test-read-cache.c test-read-cache: drop namelen variable 2019-09-06 11:03:39 -07:00
test-read-graph.c Merge branch 'gs/commit-graph-path-filter' 2020-05-01 13:39:53 -07:00
test-read-midx.c
test-ref-store.c worktree: drop get_worktrees() unused 'flags' argument 2020-06-22 10:31:15 -07:00
test-regex.c t/helper: teach test-regex to report pattern errors (like REG_ILLSEQ) 2020-05-18 13:03:35 -07:00
test-repository.c t/helper: make repository tests hash independent 2020-02-24 09:33:27 -08:00
test-revision-walking.c
test-run-command.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
test-scrap-cache-tree.c
test-serve-v2.c
test-sha1.c
test-sha1.sh
test-sha256.c
test-sigchain.c
test-strcmp-offset.c
test-string-list.c
test-submodule-config.c
test-submodule-nested-repo-config.c
test-subprocess.c
test-svn-fe.c
test-tool.c maintenance: add start/stop subcommands 2020-09-25 10:59:44 -07:00
test-tool.h maintenance: add start/stop subcommands 2020-09-25 10:59:44 -07:00
test-trace2.c strvec: rename files from argv-array to strvec 2020-07-28 15:02:17 -07:00
test-urlmatch-normalization.c
test-wildmatch.c
test-windows-named-pipe.c use strpbrk(3) to search for characters from a given set 2020-02-24 09:30:31 -08:00
test-write-cache.c
test-xml-encode.c