Commit Graph

164 Commits

Author SHA1 Message Date
Tim Hockin 6cd8b5a1cf Add an absPath type and use it for git.root 2023-05-05 13:30:11 -07:00
Tim Hockin 7e6b429362 Make all env var names GITSYNC_FOO
Still support GIT_SYNC_FOO for compat.
2023-05-04 08:45:25 -07:00
Tim Hockin 5cc7160985 Clean up all old worktrees 2023-05-04 08:45:13 -07:00
Tim Hockin 10af97f51d Move worktrees to .worktrees/*
This will make it easier to enumerate old worktrees and do better
cleanup.
2023-04-29 10:51:13 -07:00
Tim Hockin 988bfb7a01 e2e: handle log capture automatically
Same as test_git.sh
2023-04-29 10:44:07 -07:00
Tim Hockin e84a4cb4fd Make --webhook-success-status=0 the same as -1 2023-04-29 10:40:53 -07:00
Tim Hockin cbedbc0ca5 Add test for repo size and change default GC
--git-gc=always seems to be the right tradeoff.
2023-04-28 14:07:54 -07:00
Tim Hockin dc56d5d6bf Tidy up log levels - logs read better now 2023-04-28 14:07:42 -07:00
Tim Hockin f6678b98e8 Change the default depth to 1
For most users this is functionally equivalent and more efficient.  For
users who really need the full history, set this to 0.
2023-04-28 14:07:35 -07:00
Tim Hockin ee6664748f Total overhaul of sync loop
The previous (v3) sync loop betrays my lack of understanding about git.
It tried to codify my archaic mental model (e.g. --branch and --rev
being disting things) and was ultimately a patchwork of corner-cases
evolved over a few years.

This commit is less of a "diff" and more of a "rewrite".

The new logic is simpler and more efficient.  It does not `git clone`
ever.  It does not differentiate the first sync from subsequent syncs.
It uses `git fetch` to get the exact SHA and then makes a worktree from
that.

The new `--ref` flag replaces both `--rev` and `--branch`, though it
will use those if specified.  In fact, almost all of the e2e tests
passed without change - using --ref and --branch!

I will follow this commit up with more cleanups and e2es.
2023-04-21 17:25:25 -07:00
Tim Hockin f95f3c24f7 e2e: print failing line 2023-04-06 17:45:36 -07:00
Tim Hockin f4d067c987 e2e: compare numbers numerically, not lexically
Thanks, bash, for supporting `<` and `>` and making them NOT mean the
obvious thing.

This shows up when you set RUNS=10:
`[[ 2 < 10 ]]` is false
`(( 2 < 10 ))` is true
2023-04-06 17:45:26 -07:00
Tim Hockin c1b8617385 e2e: s/REV/SHA 2023-04-06 17:45:16 -07:00
Kubernetes Prow Robot 1edf40bc2f
Merge pull request #682 from thockin/v4_e2e_init_test_cleanup
e2e: rename init tests, remove default-val args
2023-02-17 04:19:56 -08:00
Tim Hockin 75a256ee24
e2e: rename init tests, remove default-val args
Also don't pass --rev=HEAD when that's not part of the test.  It's the
default value.
2023-02-16 13:58:12 -08:00
Tim Hockin c5dcd87551
e2e: move helper scripts to _test_tools/ 2023-02-15 12:22:29 -08:00
Timothy Rule 2b3f1bcdd7
Add cli option sync-on-signal to trigger git-sync with a signal. (#664)
Operation:
git-sync --repo https://github.com/kubernetes/kubernetes --sync-on-signal SIGHUP
git-sync --repo https://github.com/kubernetes/kubernetes --sync-on-signal HUP
git-sync --repo https://github.com/kubernetes/kubernetes --sync-on-signal 1

Signals can be sent to docker containers with cmd:
docker kill -signal SIGHUP <Container ID>
2023-02-15 12:00:22 -08:00
Tim Hockin bbd0f56d11
e2e: assert metrics in tests 2023-02-10 21:12:56 -08:00
Tim Hockin 14422f8bac
e2e: set MAXWAIT to change wait times 2023-02-10 16:05:52 -08:00
Tim Hockin 759b8ebdfe
e2e: print path to logs on failure 2023-02-10 15:45:55 -08:00
Tim Hockin 950e391018
e2e: set RUNS to repeat tests 2023-02-10 15:45:54 -08:00
Tim Hockin b3ee55446e
e2e: allow file:// repos (missing piece) 2023-02-06 17:51:04 -08:00
Tim Hockin 75ba836f80
e2e: fix test-tool image names 2023-02-06 17:51:03 -08:00
yoyehan 2f7335868e
Fix cases of syncing different SHAs back to back
Prior to this, it would fail if the 2nd SHA wasn't in the local repo.
Now it doesn't care what the local SHA for rev is, it only cares what is
checked out at HEAD.
2022-12-25 14:02:12 -08:00
Kubernetes Prow Robot a761413d81
Merge pull request #649 from thockin/e2e_fix_broken
e2e: fix 2 broken tests
2022-11-30 03:28:54 -08:00
Tim Hockin 59e2d9e97c
e2e: fix exechook_fail_retry
Previous e2e perf changes caused this to fail.
2022-11-24 17:50:03 -08:00
Tim Hockin a492289ebf
e2e: fix git submodules for file://
I guess upstream git intentionally broke this because of a CVE.

Also fix wait_for_sync to actually exit early when possible.
2022-11-23 23:43:27 -08:00
Tim Hockin bda1f84614
Add --touch-file flag and use it in tests
This is mostly designed to make testing easier instead of sleep.
2022-10-30 17:01:55 -07:00
Kubernetes Prow Robot 2edd4e5d9e
Merge pull request #632 from thockin/error-file-abs-path
Make --error-file allow abs paths
2022-09-11 08:47:23 -07:00
Kubernetes Prow Robot d0b7661c58
Merge pull request #630 from thockin/e2e_bad_branch
e2e: move err tests and add bad-branch
2022-09-11 07:45:23 -07:00
Tim Hockin c32a042213
Make --error-file allow abs paths
This also enforces th previously unenforced "must not start with a
period" rule.
2022-09-05 14:54:10 -07:00
Kubernetes Prow Robot cbf034f87b
Merge pull request #629 from thockin/silence_e2e_noise
e2e: Silence noise from git init
2022-09-03 03:16:27 -07:00
Tim Hockin fcb577b9fb
e2e: move err tests and add bad-branch 2022-09-02 13:45:43 -07:00
Tim Hockin 8e28337f3c
e2e: Silence noise from git init 2022-09-02 13:45:29 -07:00
Tim Hockin bcd4629159
Disable local git configs 2022-09-02 13:45:19 -07:00
Tim Hockin d4c60936ed
e2e: Allow N tests to fail and catch errexit
Prior to this, `errexit` was not active inside test functions (see
comments in this commit).

Now, multiple tests can fail - it does not abort on the first one.
2022-08-30 14:50:37 -07:00
Kubernetes Prow Robot 6e03c52fc3
Merge pull request #615 from thockin/fetch_if_depth_and_rev_not_found
Support shallow sync when the rev is not in-range
2022-08-30 02:51:01 -07:00
Tim Hockin eb33e7cfcb --max-sync-failures -> --max-failures
Deprecate but retain the old flag and env.
2022-08-21 10:48:20 -07:00
Tim Hockin ff0a73f5ad Support shallow sync when the rev is not in-range
If I ask for `--depth 1` and a branch, it's fine.

If I ask for `--depth 1` and a tag, and that tag is not within 1 commit
of the branch that was cloned, it will give an error.  Oddly, if the
initial `clone` was OK, and subsequent syncs drift, it is OK, because of
how we `fetch`.  But if it is too far away at the beginning, kaboom.

This betrays that the current model of `--branch` and `--rev` is really
broken, and should be revamped.  For now, I did something simple - if
the rev can't be found, try a fetch.  A "real" fix is more involved.

Also add tests.
2022-08-20 15:41:33 -07:00
Tim Hockin 35f0720083 e2e: basename the link when comparing 2022-08-14 15:51:09 -07:00
Tim Hockin 48b006568d e2e: also trap ERR 2022-07-26 11:27:56 -07:00
Kubernetes Prow Robot e7d6471ddd
Merge pull request #576 from thockin/v4_e2e_password_not_one_time
v4: e2e: Make password test not use --one-time
2022-07-07 23:33:49 -07:00
Kubernetes Prow Robot 9e1fc987cf
Merge pull request #574 from thockin/v4_no_XDG_CONFIG_HOME
v4: e2e: don't set XDG_CONFIG_HOME
2022-07-07 05:19:34 -07:00
Kubernetes Prow Robot 344f3ecd09
Merge pull request #570 from thockin/v4_e2e_CLEANUP_docker_rm
v4: e2e: $CLEANUP decides whether to rm containers
2022-07-07 04:43:34 -07:00
Kubernetes Prow Robot 37eba714c5
Merge pull request #568 from thockin/v4_ncsvr_http_bug
v4: e2e: Fix ncsvr to wait for input on HTTP
2022-07-07 04:27:34 -07:00
Tim Hockin 56918b0055 e2e: don't set XDG_CONFIG_HOME 2022-07-03 16:53:09 -07:00
Kubernetes Prow Robot 6898074c8a
Merge pull request #564 from thockin/v4_e2e_rebuild_less
v4: e2e: rebuild the container less often
2022-07-03 14:31:22 -07:00
Tim Hockin 20f0ab8a9b e2e: Make password test not use --one-time 2022-07-03 11:38:23 -07:00
Tim Hockin e579cf18b2 e2e: $CLEANUP decides whether to rm containers 2022-07-03 11:36:48 -07:00
Tim Hockin ec25d1a3f5 e2e: Fix ncsvr to wait for input on HTTP
This caused occasional e2e flakes when the server responded before the
client request had been sent.
2022-07-03 11:36:05 -07:00