14 Commits

Author SHA1 Message Date
Nathan Baulch
19d92613a6 chore(general): typos (#4659) 2025-06-10 17:24:14 -07:00
Jarek Kowalski
09415e0c7d chore(ci): upgraded to go 1.22 (#3746)
Upgrades go to 1.22 and switches to new-style for loops

---------

Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.com>
2024-04-08 09:52:47 -07:00
Julio Lopez
ab8680c997 refactor(general): minor cleanups related to index managers (#3518)
Rename faketime.AutoAdvance parameter to start for clarity

Clarify faketime.ClockTimeWithOffset.Advance documentation

Refactor `faketime.TimeAdvance`:
  Add `faketime.NewAutoAdvance` to create auto-advancing
  `TimeAdvance` clocks.

Refactor faketime.NewTimeAdvance to return non-auto-advancing clocks,
which can still be explicitly advanced.
Removes the now unused `autoDelta` parameter, since it is always 0.

Rename function to `sm.setupCachesAndIndexManagers`
It matches the current implementation better.

Unexport `indexblob.ManagerV1.epochMgr`

Rename function for clarity to `advanceEpochMarker`

Cleanup logs after cleaning up epoch manager.
This is consistent with quick maintenance as well.

Make 'def' a test-local variable instead of a package-level
variable, it is not used outside this test.

Cleanup epoch test newTestEnv()

Misc:
* Reword comment and fix typo
* Fix log message
* `log.Debug` for non-formatted output
2023-12-17 22:21:28 -08:00
Jarek Kowalski
65f295ed79 refactor(repository): replaced atomic values with Go 1.19 atomic wrappers (#2590)
Almost all were easy to replace, except ones exposed via JSON which
have been left as-is.

The linter has a cool behavior where it flags attempts to pass
`atomic.Int32` for example by value , which is always a mistake,
say as an argument to `fmt.Sprintf()`
2022-11-19 18:39:04 +00:00
Jarek Kowalski
daa62de3e4 chore(ci): added checklocks static analyzer (#1838)
From https://github.com/google/gvisor/tree/master/tools/checklocks

This will perform static verification that we're using
`sync.Mutex`, `sync.RWMutex` and `atomic` correctly to guard access
to certain fields.

This was mostly just a matter of adding annotations to indicate which
fields are guarded by which mutex.

In a handful of places the code had to be refactored to allow static
analyzer to do its job better or to not be confused by some
constructs.

In one place this actually uncovered a bug where a function was not
releasing a lock properly in an error case.

The check is part of `make lint` but can also be invoked by
`make check-locks`.
2022-03-19 22:42:59 -07:00
Jarek Kowalski
7735fcc525 epoch: added epoch manager + unit tests (#1128) 2021-06-11 18:57:21 -07:00
Jarek Kowalski
34da819953 faketime: fixed offset (#853) 2021-02-27 20:57:33 -08:00
Jarek Kowalski
e694367da8 lint: fixed vet-time-inject and replaced with forbidigo linter (#848)
added faketime.NewClockTimeWithOffset and used that to fix flaky
'TestDeleteUnreferencedBlobs' test.
2021-02-21 07:46:04 -08:00
Jarek Kowalski
044b170915 testing: fixed deadlock in faketime_test (#655)
TestTimeAdvanceConcurrent was depending on t.Parallel() to be scheduled
quickly, which is not guaranteed.

Fixes #654
2020-09-29 23:28:03 -07:00
Julio López
70df5f738c testing: Refactor faketime (#597)
* Allow auto-advance in faketime.TimeAdvance
* Leverage TimeAdvance in faketime.AutoAdvance
* Concurrent test for faketime.AdvanceTime
2020-09-10 00:52:14 -07:00
Jarek Kowalski
1a8fcb086c Added endurance test which tests kopia over long time scale (#558)
Globally replaced all use of time with internal 'clock' package
which provides indirection to time.Now()

Added support for faking clock in Kopia via KOPIA_FAKE_CLOCK_ENDPOINT

logfile: squelch annoying log message

testenv: added faketimeserver which serves time over HTTP

testing: added endurance test which tests kopia over long time scale

This creates kopia repository and simulates usage of Kopia over multiple
months (using accelerated fake time) to trigger effects that are only
visible after long time passage (maintenance, compactions, expirations).

The test is not used part of any test suite yet but will run in
post-submit mode only, preferably 24/7.

testing: refactored internal/clock to only support injection when
'testing' build tag is present
2020-08-26 23:03:46 -07:00
Jarek Kowalski
9a6dea898b Linter upgrade to v1.30.0 (#526)
* fixed godot linter errors
* reformatted source with gofumpt
* disabled some linters
* fixed nolintlint warnings
* fixed gci warnings
* lint: fixed 'nestif' warnings
* lint: fixed 'exhaustive' warnings
* lint: fixed 'gocritic' warnings
* lint: fixed 'noctx' warnings
* lint: fixed 'wsl' warnings
* lint: fixed 'goerr113' warnings
* lint: fixed 'gosec' warnings
* lint: upgraded linter to 1.30.0
* lint: more 'exhaustive' warnings

Co-authored-by: Nick <nick@kasten.io>
2020-08-12 19:28:53 -07:00
Jarek Kowalski
40acf238f3 Fixed arm and arm64 build. (#506)
* fixed a number of cases where misaligned data was causing panics on armv7 (but not armv8)
* travis: enable arm64
* test: reduce compressed data sizes when running on arm
* arm: wait longer for snapshots
2020-07-30 17:31:28 -07:00
Julio López
d9ce3d0ad6 Inject time in Kopia components (#314)
Motivation: Allow time injection for (unit) tests, to more easily test and
verify time-dependent invariants.

Add time injection support for:

* repo.Manager
* manifest.Manager
* snapshot.Uploader

Then, wire up to these components. The content.Manager already had support for
time injection, but was not wired up from the time function passed to repo creation.

Add an internal/faketime package for testing. Mainly code movement from testing
code in the repo/content package. Motivation: make it available to other packages
outside content Also, add simple tests for faketime functions.
2020-03-10 00:42:10 -07:00