Commit Graph

45 Commits

Author SHA1 Message Date
Brad Fitzpatrick 526640422e all: use (*testing.T).Cleanup, simplify test helper signatures
Signed-off-by: Brad Fitzpatrick <brad@danga.com>
2024-01-14 11:49:39 -08:00
Oleksandr Redko 001c417e73
all: replace deprecated io/ioutil with io and os (#1647) 2023-01-23 10:25:14 -08:00
luz paz d605f86c82 Fix various typos
Found via `codespell -q 3 -S ./clients/web/embed,./clients/chrome -L ba,everytime,impres,keypair,msdos,pres,ro,te,ue`
2022-05-02 14:31:09 -07:00
Alexandre Viau fb961cf310
make codebase go-vet-clean (#1379)
Co-authored-by: Bob Glickstein <bobg@emphatic.com>
2021-07-26 21:19:53 -04:00
Brad Fitzpatrick 0ccf258ca4 blob: specify "oh, nevermind" error value for optional SubFetcher interface
To support composition, all optional interfaces in Go need a way to
say, at runtime, that "oh, nevermind, I defensively implemented this
interface but it turns out the thing I'm wrapping doesn't support it".

We learned that lesson only in the past few years, but SubFetcher
predates that.

So do that here and make proxycache implemented SubFetcher and make
everything respect the fallback oh-nevermind error value.

Fixes #1170

Change-Id: I3c0958cf6692a324e98f526571d10a352a8e18b4
2018-05-17 19:49:02 -07:00
Brad Fitzpatrick b1abccd287 devcam, localhost, storagetest: fixes for Windows
Unset CGO_ENABLED if no sign of gcc.

The localdisk renaming stuff was fixed in Go ages ago in
golang/go#13673 and https://golang.org/cl/6140

And a defer in storagetest meant Windows couldn't delete files
because a file was still open.

Change-Id: I57aef85f24653b19ce10e3d1e18c778cee2d48f6
2018-05-01 10:46:19 -07:00
Brad Fitzpatrick 66db09453f blobserver: add context to BlobRemover
Updates #733

Change-Id: I2fffb5cad59aa994441ee82ac5d940270113ee5a
2018-01-19 09:54:46 -08:00
Brad Fitzpatrick 194d4f9443 blobserver, all: add contexts to ReceiveBlob, Fetch & million resulting deps
I had intended for this to be a small change.

I was going to just add context.Context to the BlobReceiver interface,
but then I saw blob.Fetcher could also use one, so I decided to do two
in one CL.

And then it got a bit infectious and ended up touching everything.

I ended up doing SubFetch in the process by necessity.

At a certain point I finally started using context.TODO() in a few
spots, but not too many. But removing context.TODO() will come in the
future. There are more blob storage interfaces lacking context, too,
like RemoveBlobs.

Updates #733

Change-Id: Idf273180b3f8e397ac5929c6d7f520ccc5cdce08
2018-01-18 16:22:16 -08:00
Brad Fitzpatrick 0e8980b54b blobserver: change BlobStatter interface, simplify proxycache
This addresses a long-standing TODO in the BlobStatter interface to
clean it up. Just like all new Go programmers, I misused channels in
APIs. I should've cleaned this up years ago.

While here, I also added a context.

The rest should get contexts later.

This also cleans up a few things here & there.

The pkg/client statting no longer does batching, which added a lot of
complexity. There was a comment saying something like "once we have
SPDY, we can delete this". Well, we have HTTP/2 now, so seems
deletable.

All tests pass.

Change-Id: I034ce07d9b70e5cc9e5482213368993e638d4bc8
2018-01-08 16:54:52 -08:00
Brad Fitzpatrick d6a0b05df0 Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.

After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.

This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.

Also, this only moves the lru package to internal. More will move to
internal later.

Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.

This updates some docs, but not all.

devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).

Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 16:03:34 -08:00
Stephen Searles 6b426cb10d improve proxycache and stats blobservers
improving proxycache
- added fuller sample config to the package documentation
- switched the stats caching from sorted.kv to the stats blobserver
- added a cleaning mechanism to evict the least recently used blobs
- implemented StatBlobs to actually inspect the local cache. It still
  always consults the origin, but only for the blobs necessary after
  giving the cache a 50ms headstart.
- logging a few errors that were previously ignored
- added tests modeled after the tests for the localdisk blobstore
- added a method to verify the cache, and call it on initialization
- added a strictStats option to always get stats from the origin
- filling in cacheBytes on initialization

improving stats blobserver
- implemented a few more of the blobserver interfaces, Enumerator and
  Remover
- Fixed a bug(?) in ReceiveBlob that seemed to prevent it from actually
  storing stats
- added a test

minor improvements include:
- blobserver/memory: allowing the memory blobserver to hold actually
  infinite items, if desired
- blobserver: closing dest in the NoImpl blobserver, as required by the
  BlobEnumerator interface
- storagetest: not closing dest leads to deadlock
- lru: max entries of 0 now means infinite (maybe do anything <0?)
- test: a helper function to create a random blob using a global random
  source that is, by default, deterministic, to make test results more
  consistent.

In the future, an improved BlobHub or similar interface could allow a
tighter feedback loop in providing cache consistency. i.e. the cache
could register with backend stores to be notified of content updates,
minimizing the time between backend changes and cache correction.

The proxycache will verify itself at startup, reporting an error if
any of its blobs do not exist in the backend storage or if the backend
storage has a different size for the content than the cache.

Fixes #443

Change-Id: I9ee1efd8c1d0eed49bb82930c2489a64122d3e00
2017-12-29 10:09:15 -08:00
Paul Lindner c58e07942e all: lint fixes for "if block ends with a return statement"
Change-Id: I1c244f14995478860c19695695f287d541a7a39c
2017-12-13 11:31:25 -08:00
Paul Lindner 15feaeb24c all: lint fixes for 'error strings should not be capitalized or end with punctuation or a newline'
Change-Id: I9c3766a51ac8be694ae76befff4b6fa9a85e34eb
2017-12-11 06:13:25 -08:00
Paul Lindner b09cd377d7 Switch to stdlib context from golang.org/x/net/context
This switches most usages of the pre-1.7 context library to use the
standard library.  Remaining usages are in:

  app/publisher/main.go
  pkg/fs/...

Change-Id: Ia74acc39499dcb39892342a2c9a2776537cf49f1
2017-11-26 01:12:26 -08:00
Filippo Valsorda 6ea5dfb3bc storagetest: fix to pass when RemoveBlobs is not implemented
Before it would still call testEnumerate(0) even if it detected
RemoveBlobs as not implemented, which of course would fail.

Change-Id: Ic555f33fbe2e001fc6f52528e22b6faed5c7ec66
2017-02-04 23:09:45 +00:00
mpl 9e9d5e0bf2 blobserver/cloudstorage: use cloud/storage Client
Using go4.org/cloud/google/gcsutil
for the things we can't yet do efficiently with the cloud/storage
Client.

Fixes issue #652

Change-Id: I8a43a754c4e0762629ce2a21bb95d9991f6f4771
2016-04-27 11:25:58 -07:00
Will Norris 77ed42edf8 add canonical import paths
The import path was added to the go file that included the package
documentation if one existed.  Otherwise, I used what seemed to be the
primary file for the package.

Fixes #689

Change-Id: If51be0e86529fd6f179e80af6781e639f8550fd2
2016-03-13 19:57:14 -07:00
Tamás Gulácsi 9f7e1df32b Remove pkg/context
Use golang.org/x/net/context instead.

Fixes #648.

Change-Id: I676a2f25458be97610a49d6f954f2102cbd373fa
2015-12-12 23:09:02 +01:00
mpl 12eddf9c19 vendor: go4.org/strutil go4.org/syncutil
They were internal packages (under pkg), which we are now moving to
go4.org, so we in turn need to vendor them in now.

Change-Id: I92224f731404d0bd4ca1c57492bed37cb3367ed4
2015-11-21 00:21:20 +01:00
mpl b6eb85631c blob SubFetcher: explicitely states with errors the testSubFetcher constraints
testSubFetcher in blobserver/storagetest was already checking that we'd
get specific error messages in the case of negative input parameters or
an out of range offset.

This change rationalizes these constraints with named errors
(ErrNegativeSubFetch and ErrOutOfRangeOffsetSubFetch) specified
in the SubFetcher interface.

It also fixes the googlestorage and s3 implementations so that they pass
the aforementioned test.

Change-Id: I25b72b842855b90ee3cab44c90654581dccf4b8e
2015-02-26 15:18:27 +01:00
Tamás Gulácsi 7f995f3048 storagetest: test SubFetch with invalid offsets
Fix this newly introduced test case where it fails:
memory, localdisk and diskpacked blobservers.

Change-Id: Idb4b4173c3a03b64e0eb73d5fcfd9994e3e23bcc
2015-01-01 19:32:51 +01:00
Brad Fitzpatrick dcf1da7fcd blobserver/storagetest: revert TestStreamer back to only requiring a streamer
Fixes the build.

Change-Id: I76141148bc0564e9ef82ef09fc15c4485b43333c
2014-12-30 22:47:05 -08:00
Brad Fitzpatrick 1d8ffdd2db blobserver/storagetest: more paranoia and debug info on failure in TestStreamer
Change-Id: Ie98503038ef568d5d3e71860978bff846d77da4f
2014-12-25 19:19:57 -08:00
Brad Fitzpatrick b3d751594c blobserver/storagetest: remove debug log
Change-Id: I3d6389a3444284ad325ef74a6918bd4c824ffb95
2014-12-25 16:25:17 -08:00
Brad Fitzpatrick 6e3fc37ae5 blobserver/storagetest: make TestStreamer stricter, compares against Enumerator
Also then fix up diskpacked to work under these stricter rules.

Noticed this while working on blobpacked's tests and noticed them
surprisingly pass at one point. Now they no longer pass (as they
shouldn't yet, since parts are still TODO).

Updates #532

Change-Id: Ie05d19823453594486caf921cabbd149c43df221
2014-12-25 16:15:46 -08:00
Brad Fitzpatrick a082382f33 blobserver: simplify interface more, add NewMultiBlobStreamer, storagetest func
This is round two of simplifying the BlobStreamer interface. The
continuation tokens are now sent per-item. This permits the following
item (NewMultiBlobStreamer) but also simplifies the return value (only
returns an error now) and permits the use of buffered channels as the
destination without getting out of sync.

The new NewMultiBlobStreamer is like io.MultiReader, but for
BlobStreamers, letting them be stitched together. This will be used by
the blobpacked storage layer to simplify its code, so it doesn't need
to deal with the handoff between loose and packed blobs itself.  This
MultiBlobStreamer needs a 1 element buffer, which wasn't compatible
with the old BlobStreamer interface, hence the change to include the
continuation tokens with the blob on the channel.

Finally, add a new storagetest function for testing any blobstreamer
and use it for NewMultiBlobStreamer, diskpacked, and later in
blobpacked.

Updates #532

Change-Id: Iccffed289adec93ca5100c7ef8b0a8d57e05833c
2014-12-23 17:49:12 -08:00
Brad Fitzpatrick 5c0d51e565 storagetest: clean up a bit
Change-Id: I458b9be22e1559adbc3aa645434e67e21cae43de
2014-10-28 04:08:44 -07:00
Brad Fitzpatrick 4f9c8aea72 blobserver/blobpacked, storagetest: fix context goroutine leak
Change-Id: I09abd7ef203fe267219a52a57f8627ce7e28d80d
2014-10-15 12:28:49 +02:00
Brad Fitzpatrick 0f97897f81 blobserver/google/cloudstorage: make it a SubFetcher
For blobpacked.

Change-Id: Ibca3d8a6976d8e1d4058e8d7fcdca6b63f8d8b87
2014-10-11 16:02:31 +02:00
Brad Fitzpatrick 940c00a7a4 blobpacked: always fall through to the small storage
Change-Id: I8168bb3692d221e41f6bec053a12f7e5e5a1f667
2014-09-22 23:31:10 -04:00
mpl 823ad224e9 blobserver/gdrive: fixes to receive and remove + added tests.
1) Added fix in Upsert to allow for new file creation

2) Changed some methods argument s/id/title/ because it's actually the
file title that was meant to be worked with.

3) Fixed Trash to operate on a file title. Otherwise RemoveBlobs is
broken since blobRefs are used as the title when receiving, not as the
id.

4) Added tests.

5) Added option to storagetest to allow for skipping enumerate tests,
since enumerate not supported on gdrive yet.

Change-Id: I1f13f10214d816df53ff30e27e4e72085a31ba20
2014-09-19 20:16:05 +02:00
Brad Fitzpatrick 8fd3277b06 storagetest: slight refactor, add support for options.
Currently unused. Added a Retried option, thinking I'd need it. I might later, or we might
add more options later.

Change-Id: I6b2f63c22685fd964012adbc8dfa06f3f6344313
2014-08-25 19:04:18 -07:00
Brad Fitzpatrick 2016613018 storagetest: test SubFetchers
Change-Id: I0e5a3559523617e28a57a592fb5bebb881eebd16
2014-08-25 16:44:40 -07:00
tnt 4ac9938c8b Fixed some formatting functions that were called with invalid number/type of arguments.
Change-Id: I261c6fb732a6cf1e54e01fa3e5388c39c6deb720
2014-07-01 12:48:33 +02:00
tnt 5d8eeb534b Fixed wrong calls to formatting functions.
E.g: fmt.Println("%s", "hello world") -> fmt.Printf("%s", "hello world")

Change-Id: I51c0bd54c14173e074fafd86c83a5287fcdb1520
2014-06-30 22:05:22 +02:00
Tamás Gulácsi bc39d9888c Diskpacked: support deletion
Delete from index and zero out blob's data.
Use FALLOC_FL_PUNCH_HOLE if available (linux >= 2.6.38).

Change-Id: I0c194fd6734a35b520212398d93dfdc5cabadeb5
2014-03-20 21:20:36 +01:00
Brad Fitzpatrick bfe61b1297 storagetest: add a test of EnumerateBlobs w/ prefix of a blobref
Change-Id: Id865da5ba6c65e0110b0eb6c6d0bd45980d33105
2014-03-18 13:47:02 -07:00
Brad Fitzpatrick bf94a73859 Get rid of SeekFetcher vs StreamingFetcher distinction and complexity.
StreamingFetcher is now just Fetcher, and its FetchStreaming is now
just Fetch.

SeekFetcher is gone. Blobs are max 16 MB anyway, so we can slurp to
memory when needed. The main thing that cared about SeekFetcher
was the GET handler, ServeBlobref, because http.ServeContent needed
one for range requests. That's rewritten in an earlier commit, using
the FakeSeeker from another earlier commit.

Lot of code got simpler as a result.

Change-Id: Ib819413e48a8f9b8d97f596d0fbf771dab211f11
2014-03-14 12:29:13 -07:00
Antti Rasinen f837fcb9d8 Convert all S3 requests to HTTPS
Also includes fixes for two missing data items
for errors.

Change-Id: Ib174b4bf83f3f264f463b4c203c1f42213b18f5e
2014-03-09 21:00:13 +02:00
Tamás Gulácsi 97520583b8 Use 'uint32' instead of 'int64' for blob sizes everywhere.
Not just in blob.SizedRef, but in blobserver.Fetch and
blobserver.FetchStreaming, too.
Blobs have a max size of 10-32 MB anyway, and the index.Corpus is now using
uint32 to save memory.

Change-Id: I1172445c2f9463fdaee55bfe0f1218d44be4aa53
2014-02-08 17:58:12 +01:00
Brad Fitzpatrick aebc8f00c6 cond: add test using storagetest
Change-Id: Iffd987de42d82e1c19ff2c984ff3d2f01824e34c
2014-01-20 10:37:23 -08:00
Brad Fitzpatrick b82b8efe4c Start of new context package and *context.Context type.
Will eventually be plumbed through lots of APIs, especially those requiring or benefiting from
cancelation notification and/or those needing access to the HTTP context (e.g. App Engine).

Change-Id: I591496725d620126e09d49eb07cade7707c7fc64
2013-12-02 13:20:51 -08:00
Brad Fitzpatrick 7466336f44 storagetest: more tests, and simplify a bit
Change-Id: Ic0d6c9718ef79ff82f05cf142286022862f30236
2013-12-02 11:57:02 -08:00
Tamás Gulácsi f69306cbee Finish implementing storagetest
Add use into localdisk (diskpacked already uses it).
Add ErrNotImplemented error for blobserver and mention the possibility
for RemoveBlobs (diskpacked deficit).

Change-Id: I6a50f263a58c8d3d1611ff9a060ea9fa4aee6163
2013-12-01 21:05:37 +01:00
Brad Fitzpatrick f544114844 Fix diskpacked regression, add tests, start of storagetest.
Regressed from rev cb6f423e. Eventually pkg storagetest should test all methods of blobserver.Storage
for all storage target types.

Change-Id: I2c1c93b76fd9280a3eb429b1d71c64a693ed1ace
2013-11-30 13:06:04 -08:00