Commit Graph

201 Commits

Author SHA1 Message Date
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
Tim Hockin 4b9431f9bc Don't run apt-get in e2e build if we can avoid 2022-07-03 11:35:09 -07:00
Tim Hockin 10abfd561b e2e: rebuild container less often 2022-07-03 11:35:09 -07:00
Tim Hockin 27ac1642c9 Rename tests for better filtering 2022-07-03 11:14:46 -07:00
Tim Hockin 23540b9d94 Beef up askpass_url support
* Don't need to get the password at startup (it happens in the sync loop
  anyway)
* Add tests for bad password and flaky URL
2022-07-02 15:43:27 -07:00
Kubernetes Prow Robot d8da63cf48
Merge pull request #557 from thockin/v4_e2e_v6
v4: e2e with -v=6
2022-07-02 13:11:24 -07:00
Kubernetes Prow Robot 58bb41e82f
Merge pull request #538 from thockin/v4-dont-docker-kill
v4: e2e: Don't manually "docker kill"
2022-07-02 12:59:24 -07:00
Tim Hockin 2a4ca7794c e2e with -v=6 2022-07-02 10:59:47 -07:00
Kubernetes Prow Robot 52d2e075c6
Merge pull request #542 from thockin/v4-passwd_e2e_split
v4: Split password test to 2 - right and wrong passwd
2022-07-02 03:53:24 -07:00
Tim Hockin 00d81fd3f9 Split password test to 2 - right and wrong passwd 2022-06-24 08:46:43 -07:00
Tim Hockin 5b7df08826 e2e: Reformat ncsvr scripts for readability 2022-06-24 08:45:17 -07:00
Tim Hockin 9af6b7cfe2 e2e: Don't manually "docker kill"
It happens automatically on test cleanup
2022-06-24 08:45:05 -07:00
Tim Hockin a341fb62f9 Make ssh e2e test not use --one-time
There is functionality that needs to be tested beyond that.
2022-06-11 10:56:20 -07:00
Tim Hockin 2c6356cbcb Pass CLEANUP=0 to test_e2e to leave logs 2022-06-11 19:49:11 +02:00
Tim Hockin f8a532d9df Pass the whole environment to exechooks 2022-05-16 18:14:09 -07:00
Tim Hockin 535735607f Adapt testcases for v4 2022-03-11 08:41:57 -08:00
sed-i ff3d11c925 Add repo-sync test 2022-03-11 08:34:16 -08:00
Tim Hockin 8c5f33d5dd Make e2e treat args as tests-name regexes 2022-02-24 09:00:57 -08:00
Tim Hockin f4d124bded Add --git-gc flag to control GC on each sync
Values:
* "auto" - run `git gc --auto` (default, respects git gc.* configs)
* "always" - run `git gc`
* "aggressive" - run `git gc --aggressive` (may require a longer timeout)
* "off" - do not run `git gc` on each sync (good for --one-time use)
2022-02-24 08:00:10 -08:00
Tim Hockin 2538d293ba Set repoReady even when there wasn't a 1st clone
E.g. if the repo is already present (after a restart).
2022-02-12 17:38:36 -08:00
Kubernetes Prow Robot d3324e0b90
Merge pull request #478 from thockin/v4-link-abspath
Allow --dest to be an absolute path (v4)
2022-01-23 02:41:56 -08:00
Kubernetes Prow Robot 6dc0e44697
Merge pull request #472 from thockin/master
Don't try to remove the root if it appears corrupt (v4)
2022-01-23 01:15:56 -08:00
Tim Hockin 4fc67f5f5f Allow --dest to be an absolute path
This means it might live outside of --root.
2022-01-22 23:39:56 -08:00
Tim Hockin 248a53461d Don't try to remove the root if it appears corrupt
The `--root` is often a volume and can't be removed.  Instead, remove
the contents of it.  Adjust tests to hit this.
2022-01-22 14:28:09 -08:00
Tim Hockin 9eed6946b7 e2e cleanup
Fix some whitespace and names.
Make command-line and flag handling a bit cleaner.
2022-01-19 11:38:23 -08:00
ChrisERo 5490b721d8 fix: made tests more efficient by waiting less 2022-01-14 13:53:09 -05:00
ChrisERo 043c356c03 fix: fixed e2e tests
Resolved a few issues with e2e tests discovered after running
test_e2d.sh. Just finished setting up Linux (Fedora) environment in
which this script can be run.
2022-01-14 03:23:20 -05:00
ChrisERo 0246fb509f feat: added e2e --one-time tests for webhook 2022-01-10 20:06:25 -05:00
ChrisERo 8e098f8c2a fix: made exechook_once tests more efficient
* Removed multiple iterations of tests
* Reduced sleep time after GIT_SYNC command execution
2022-01-10 20:06:24 -05:00
ChrisERo a362b4a5f4 feat: added tests for this PR that test exechook paired with --one-time flag 2022-01-10 20:06:21 -05:00
Tim Hockin 7b32caee77 v4: use repo default branch instead of master 2021-11-01 23:05:48 -07:00
Tim Hockin 2b471ba2d7 E2E: build IFF running tests 2021-10-18 09:36:52 -07:00
Tim Hockin 6e52fb0d22 E2E: Add whitespace for reading 2021-10-18 09:36:52 -07:00
Tim Hockin 320a4a7e93 E2E: Move code
Reduce the diff between v3 and v4
2021-10-18 09:36:52 -07:00
Tim Hockin 27f2c905fc E2E: Rename test funcs 2021-10-18 09:36:52 -07:00
Tim Hockin dfcafc9ca0 E2E: Fix endless loop on error 2021-10-18 09:36:52 -07:00
Tim Hockin e2ed136aad E2E: make all test cases be funcs
Make all test cases functions so they can be called individually on the
CLI.  Call test_e2e.sh with `-?` to list tests.   Fix related crashes
(uses of $TESTCASE and so on).
2021-10-18 09:36:52 -07:00
Tim Hockin e06f9c6acb E2E: Make SIGINT handling more complete 2021-10-18 09:36:52 -07:00
Tim Hockin 7b3454e51b E2E: Use vars for branch names 2021-10-18 09:36:52 -07:00
Tim Hockin 286175cb94 E2E: always use '[[ ]]' 2021-10-18 09:36:52 -07:00
Tim Hockin a91777288a use branch revision during worktree add (v4)
This is a port of the v3 commit 2c3bb035f6
2021-10-18 09:32:57 -07:00
Tim Hockin 4d286fc44f Fix e2e cases to not destroy logs 2021-10-18 09:32:57 -07:00
Tim Hockin 0075df238c Make exechooks work like webhooks.
This deprecates the `--sync-hook-command` flag in favor of
`--exechook-command`, `--exechook-timeout`, and `--exechook-backoff`.
2021-08-16 23:21:20 -07:00
Tim Hockin d1afc12e67 Handle a race between ls-remote and fetch
This is a port of PR #413.
2021-06-23 12:51:15 -07:00
Tim Hockin ab0fe416de Rename slow_git to slow_git_clone
Making room for slow_git_fetch upcoming.
2021-06-23 12:28:12 -07:00
Tim Hockin 530ac2899b Clean up worktree dirs during sync loop
Avoid "already exists" error.  This is a port of #412 but I changed
the e2e to use `docker pause`.
2021-06-22 15:07:16 -07:00
Tim Hockin 9b1bfc7a97 Make e2e pass on v4 2021-06-22 15:04:00 -07:00
Tim Hockin c6878026a1 unbreak e2e for github 2021-06-22 08:29:30 -07:00
Tim Hockin 421fc4e298 Add a testcase for github HTTPS 2021-05-28 14:18:58 -07:00
Tim Hockin 0222a95f29 Make sure all code files have headers 2021-05-27 08:46:00 -07:00
Tim Hockin 16c3bf7dd1 move test cleanup to the end 2021-05-26 14:31:16 -07:00
Tim Hockin a3d9b673a8 Port #372 to v4 dev branch (from SpencerMalone)
Wanted to finally tackle #54, I sidestepped the problem of how to handle the volume of flags that might be required by instead specifying a sparsecheckout file.

The workflow as I've had has been...
- Do a local sparse checkout, add the files you want ignored (or included on if you did a cone pattern https://git-scm.com/docs/git-sparse-checkout#_cone_pattern_set)
- Grab your .git/info/sparecheckout file, and reserve it for later use with this new flag

It's not quite as easy as specifying it all from a CLI, but I think it's a reasonable first pass.

Here are some logs of it being run on https://github.com/SpencerMalone/logstash-output-prometheus:

```
test-repo % cat sparseconfig
!/*
!/*/
README.md
test-repo % docker run --rm -d \
    -v $(pwd)/git-data:/tmp/git \
    -v $(pwd):/test \
    docker.io/registry/git-sync:tag__linux_amd64  \
        --repo=https://github.com/SpencerMalone/logstash-output-prometheus.git \
        --branch=master \
        --sparse-checkout-file=/test/sparseconfig
41494548dd64caf0ff8f7b75e4d3a86014cfaefc40ff31b14ba19accf99aa82f
test-repo % ls git-data/db86200b1ab158ce9ad403d06de2301b15333601
README.md
```

As you can see, I ignored everything but the `README.md`, and sure enough only got that file in my final checkout.
2021-04-23 09:01:05 -07:00
Nan Yu f2581cff93 Export the error details to an error file
The current git-sync process outputs the error information to standard
out, which is inaccessible from outside the container. Users have to
dump the logs using kubectl logs in order to check the error details in
the git-sync process. This commit exports the error details to a file,
which provides users the capability to check the errors directly from
other sidecar containers.

proposal: https://github.com/kubernetes/git-sync/issues/326
2021-04-09 11:33:16 -07:00
Kubernetes Prow Robot 13af14e3bf
Merge pull request #370 from thockin/exec-hook-after-symlink-v4
Move sync-hook to after symlink flip
2021-04-07 16:47:42 -07:00
Tim Hockin d6c1fd3c6b Move sync-hook to after symlink flip 2021-04-05 17:02:00 -07:00
Tim Hockin dcb918f846 WIP: startup tests 2021-03-29 16:48:50 -07:00
Kubernetes Prow Robot 7b594781f8
Merge pull request #344 from thockin/fix-pid1-exit-code-v4
Fix exit non-zero exit codes when running as pid1
2021-03-15 09:39:06 -07:00
Tim Hockin 45b28530a7 Fix exit non-zero exit codes when running as pid1
(v4 branch)

Prior to this we would swallow the exit code and always exit(0).
2021-03-15 09:28:26 -07:00
Tim Hockin 83b4dd21de Add --git-config flag
This allows arbitrary git configs to be passed in.  For example:

`git config --global http.postBuffer 1048576000`

`git config --global http.sslCAInfo /path/to/cert/file`

`git config --global http.sslVerify false`

This flag takes a comma-separated list of `key:val` pairs.  The key part
is passed to `git config` and must be a valid gitconfig section header
and variable name.  The val part can be either a quoted or unquoted
value.  For all values the following escape sequences are supported:
   * `\n` => [newline]
   * `\t` => [tab]
   * `\"` => `"`
   * `\,` => `,`
   * `\\` => `\`

Within unquoted values, commas MUST be escaped. Within quoted values,
commas MAY be escaped, but are not required to be.  Any other escape
sequence is an error.

Example:

`--git-config=foo.one:val1,foo.two:"quoted val",foo.three:12345`

This commit exposed a bug in runCommand() which modified its args when
they had an embedded space.
2021-03-15 09:20:02 -07:00
Tim Hockin e5a438e446 Change the symlink targets to just the SHA
This allows users to call readlink() on the link and learn the current
checked out SHA.
2021-03-11 22:11:35 -08:00
Tim Hockin ccde597b7d Always specify branch name in e2e
As git changes the default from "master" to "main", it's not
predictable.  Now the test owns the decision.

This was already merged on release-3.x.
2021-01-23 16:13:26 -08:00
Tim Hockin a285a770e2 Use docker to run helper servers in e2e
Reliably cleaning up leftover things like `nc` processes is surprisingly
difficult in pure shell.  e2e passes on the master branch now.
2021-01-23 15:59:24 -08:00
Tim Hockin 24c06a5b48 Normalize the root path
This makes sure there's never any confusion about whether it is an
absolute path or has symlinks or whatever.  Add e2e cases to cover.
2020-11-09 09:20:24 -08:00
Tim Hockin 0e802450ee Don't allow --dest to start with a dot
BREAKING CHANGE

It's useful to reserve names that start with a dot.
2020-11-09 08:36:10 -08:00