Commit graph

53 commits

Author SHA1 Message Date
Lory Cloutier
b6ae088f24 FB-1766: cleaning up the CmdIO objects passing alternate stdin/
stdout/stderr around

A lot of functions in the cmd and ctl packages were passing these
around and barely using them. Replaced them with a logger for most
functions. Some functions get an io.Writer instead so that their
tests can find the output they're looking for.

More cleanup on fb-1766: reworked the tests that were using io.Pipe
or os.Pipe to check their results so they now use a bytes.Buffer.

Unexported some variables that didn't need to be exported.
Fixed NewConfigCommand to use the provided stderr, not os.Stderr.
Added tests for rbf_dump, rbf_page, and keygen, since those weren't
being tested at all.

Added chksum_test, final cleanup.

(cherry picked from commit f627199acb)
2022-12-12 09:01:20 -08:00
Seebs
3c05f1ff37 Distinguish between usage errors and other errors
Cobra automatically displays usage messages, and also a gratuitous
"Error: [...]" line in some cases, when any error at all occurs
running a command. To suppress the usage message, you have to set
cmd.SilenceUsage to true. But the code that would do this doesn't
have access to it. To address this, we introduce a category of
"usage error", implemented with stdlib error wrapping (%w) and
use errors.Is to check for it. There's also utility functions
to do this checking automatically, or indeed, to handle wrapping
of the ctl.SomethingCommand and handle running it with a suitable
context and everything.

In fact, several of the places we're checking for usage errors,
we can never actually report one, but we're checking consistently
so that if we want to report usage errors, we can.

For instance, server.Start and (dax)server.Start don't ever
return usage errors, right now, but we're checking their responses
anyway.

(cherry picked from commit c681642734)
2022-12-12 09:01:20 -08:00
Garrison Davis
ab2b48da0d Stop using string keys in contexts
This fixes the OriginalIP and RequestUserID in the main featurebase
package, and the Access and Refresh tokens, the UserInfo, and the
[]string of Indexes passed with context.Context(s) in the authn package.

An empty struct was used for all of these keys (and relevant helper
functions we added) to avoid allocations where possible while still
using the context functionality.

Some of the logic in the server.GetIndexes function was fixed.

(cherry picked from commit 0f5a56c958)
2022-11-15 11:32:03 -08:00
Seebs
e47bdb7889 cleaned up sync from private repo 2022-09-30 11:20:58 -07:00
Seebs
f6d17b1b58 refactor testing to share clusters more often
When doing tests, we create a ton of one-off clusters. This
turns out to be expensive and slow. Fixing it is surprisingly hard.

Fundamentally: If we're sharing clusters, we need to use different
indexes for each test, to avoid clashes. This changes index names.
As a side-effect, this reorders many partition-based things, like
the order keys are returned in. Thus, to fix this, we change a lot
of tests to no longer depend on the *order* in which strings are
returned.

Having done that, we can also discard the ModHasher behavior, since
that only existed to allow us to reliably predict partitioning.

The basic design is as follows: Instead of a cluster being a
[]*Command, a "shareable" cluster is now a []*Command plus some
flags, and a "cluster" is a pointer to a possibly-shared cluster,
plus a link to the specific test using this specific cluster,
and correspondingly, its test name suitably coerced to be a valid
index name prefix.

The "test.Cluster" object now has methods to allow retrieving an
index name, and also implemnts fmt.Formatter to let you use,
e.g., `%i` with it in Sprintf to get "the index name, plus an i".
(This works for everything but %p and %T.)

This allows us to consistently rework all the many things that
use index names in a persistent way.

We also have `MustUnshared` and `MustRunUnsharedCluster` methods
which allow us to specify that a given test needs its own cluster
for some reason. For instance, the tests that want to run backups
need their own isolated cluster, and the tests that want to close
or reopen nodes need their own cluster because a reopened cluster
won't have working GRPC for some reason.

On "closing" a shared cluster (actually the test-specific wrapper
that reflects a given sharing), we delete any indexes starting with
that test's index name prefix. Otherwise, the huge pile of open
indexes prevents `go test -race` from working on MacOS, where we
run out of address space too quickly.

This is fairly enormous but most of the individual changes are
fairly trivial things like replacing the string "i" with "c.Idx()".

We also tweaked a test that failed for me a couple of times to
not depend on sort order.
2022-09-30 11:10:47 -07:00
Seebs
6207da9c48 reduce size of KeyReplication test
This test used to be large, because it was testing some features that
were refactored out in October of 2019. Since we no longer have the
"buffer growth" to check, let's check a much smaller file.
2022-09-30 11:10:47 -07:00
CLoZengineer
f9ddb5d5c1
fix: updating code to meet linting requirements (#2171)
* removes unused filesize function

* removes ioutil usage

* updates ioutil.ReadAll to io.ReadAll

* updates ioutil.TempFile to os.CreateTemp

* updates ioutil.TempDir to os.MkdirTemp

* updates ioutil.ReadAll to os.ReadAll

* update ioutil.WriteFile to os.WriteFile

* updates ioutil.Discard to io.Discard

* updates ioutil.ReadDir to os.ReadDir where applicable

* removes unused code in idk

* creates type to use for context value keys

* replaces assert.Nil with assert.NoError for error checks
2022-09-29 12:34:29 -04:00
Fletcher Haynes
da9b57bd45 Updated dependency paths to reflect new repo location 2022-09-06 09:39:22 -07:00
Fletcher Haynes
eb06bb50ae Updated code to latest version for open-sourcing. 2022-09-02 13:23:39 -07:00
Ben Johnson
c7c9c1e1d7
v2.0.0
Co-authored-by: Cody Soyland <codysoyland@gmail.com>
2019-10-08 14:56:17 -06:00
Matt Jaffee
9e6662fb00
send POSTed schema to all nodes in cluster
also fix a *bunch* of tests that weren't closing the clusters they
created. Cleaned up one test to use t.Run instead of just checking
everything in a loop
2019-04-29 19:31:23 -05:00
Seebs
79451bd53c undo accidental change to test case contents 2019-04-16 12:07:18 -05:00
Seebs
77d49ded64 so much lint
So with the switch to a new linter, we get a lot of new warnings,
and the majority of them are harmless probably, but a few might be
real. Variously just use _ to suppress warnings, or report errors.
There's probably things here that deserve better fixes, but we can
always revisit it.
2019-04-16 12:07:18 -05:00
Travis Turner
358c32a165
add test for translate store buffer growth logic. add max limit to buffer size. 2018-12-18 12:48:20 -06:00
Travis Turner
a7a15c64a2
support clear imports to int fields. fix bug in fragment.sum 2018-10-23 17:37:57 -05:00
Travis Turner
caf8e06712
add clear functional option for imports 2018-10-23 17:37:57 -05:00
Travis Turner
4f17dbdbf1
add support for Bool fields
prevent import of non-boolean row values to bool fields
2018-09-21 09:25:41 -05:00
Travis Turner
177f25ee44
Add tests for importing value with column keys into integer fields.
Fix a bug in protofuf decoding of pilosa.Row.
2018-08-15 16:00:32 -05:00
Travis Turner
0a6f0e92d8
add tests to cover the coordinator logic for multi-node clusters 2018-08-14 13:58:37 -05:00
Cody Soyland
d4510172d3 Fix linter issues: ineffassign 2018-07-18 14:02:56 -05:00
Matt Jaffee
5ff77c816a
get rid of unecessary server stuff and export node and uri 2018-07-03 13:26:51 -05:00
Cody Soyland
824474160e Enhance test utilities (introduce Cluster type, improve naming) 2018-06-28 13:34:58 -05:00
Matt Jaffee
9998eda3d4
remove Server.Addr - use URI instead 2018-06-27 13:37:08 -05:00
Matt Jaffee
8878b02345
cleanup - address review feedback 2018-06-25 11:08:00 -05:00
Matt Jaffee
6093064ac0
remove unecessary test and convert import test 2018-06-22 16:26:45 -05:00
Matt Jaffee
5d28d2dc31
skip new tests which use test.NewServer 2018-06-22 13:00:52 -05:00
Matt Jaffee
7a5adf7428
Merge branch 'develop' into wip-api-refactor 2018-06-22 12:46:19 -05:00
tgruben
4b72489997
Merge branch 'develop' into crash-value-overwrite 2018-06-21 20:10:54 -05:00
Todd Gruben
643e5e575a fixed crashing issue that was not handling container removal/recycling correctly 2018-06-21 18:39:06 -05:00
Cody Soyland
e2512ec58d Use test.MustRunMainWithCluster in ctl tests 2018-06-21 16:26:34 -05:00
Cody Soyland
c6db3974bc WIP API refactor 2018-06-21 13:51:31 -05:00
Todd Gruben
aac2397949 enforced Accept for json response endpoints 2018-06-20 13:13:46 -05:00
Travis Turner
2a9b1e9e5b
final Frame to Field rename 2018-06-06 01:27:12 -05:00
Travis Turner
3531c128c4
GoRename Frame to Field in index.go 2018-06-05 22:33:48 -05:00
Travis Turner
0d44e586cc
remove field flag from pilosa import command 2018-06-05 16:14:26 -05:00
Travis Turner
dbb4cdf390
adjust the tests to match the new unexported Field and FrameOptions 2018-06-04 14:45:28 -05:00
Yuce Tekol
164b7619aa
Removes bench command 2018-05-30 16:40:21 +03:00
Travis Turner
43ec69d08b
API.URI was not being used. removed it. 2018-05-09 09:32:18 -05:00
Matthew Jaffee
fe0ba6280f
deprecate RangeEnabled, but leave in API
the RangeEnabled option now has no effect, but it still exists in the API. A few
tests still use it to ensure this. This would only be considered a breaking
change if someone was relying on Pilosa to enforce the RangeEnabled: false
option to prevent fields being created in certain frames. This seems unlikely.
2018-04-16 16:08:04 -05:00
Matthew Jaffee
3f303d1098
remove global defaults from config.go
these were occaisionally referenced elsewhere in the codebase - in all but one
case, there were workarounds that are actually better I think.

In the one case there wasn't I created a single top level DefaultConfig object
which is instantiated with all the default values and can be referred to if
necessary.

There was a bug in fragment.go with the way MaxWritesPerRequest was treated if
it was 0. Elsewhere, 0 meant no limit, but here, it would have caused a division
by 0.

Changed the default metrics provider from "nop" to "none", although "nop" will
still work. Previously, any value other than "statsd" or "expvar" was treated as
"nop", but I've changed this behavior to return an error if an invalid string is
provided. I think this is better behavior, because in the case that someone
bothered to change the default, they were probably interested in actually
getting stats, and might be annoyed when it silently failed.
2018-04-12 19:52:48 -05:00
Matthew Jaffee
f8cb579187
get tests passing 2018-04-09 14:29:43 -05:00
Yuce Tekol
c36dd395e6
All tests pass 2018-04-03 15:20:33 -07:00
Travis Turner
62cd22f017
Merge branch 'master' into cluster-resize 2018-03-22 16:05:20 -05:00
Ilias Dimos
13e3b04443 Fix misspells in comments 2018-03-09 14:12:15 +02:00
Travis Turner
216ba7a41e
Use NodeID instead of URI for node identification 2018-02-02 15:58:46 -06:00
Travis Turner
a8871ada6a
Convert Host to URI.
Fix all compile errors.
2017-10-25 11:52:55 -05:00
Yuce Tekol
e223ec3f9a
Rename Host -> URI 2017-10-12 15:49:34 +03:00
Yuce Tekol
a95b09d30d
more host string to uri changes 2017-10-04 15:29:00 +03:00
Travis
9110d52573
Add tests for ImportFieldValue 2017-09-27 11:43:11 -05:00
Yuce Tekol
ad05938a5e
Enables auto-creating the schema on imports; Resolves #765 2017-09-22 14:56:36 +03:00