Commit graph

9378 commits

Author SHA1 Message Date
Hoang Pham
a7fbbd24d8 FB-1339 - UI - updated lodash version to fix gitlab vulnerability 2022-09-13 09:19:19 -05:00
Seebs
0c91270eb1 bump to go 1.19.1 because there's no longer a docker image for 1.19 2022-09-09 17:10:57 -05:00
Seebs
782faa3354 squash auth tests into regular smoke tests, improve smoke tests
This is a bit complicated and entangled, sorry.

First, we squash the auth-based smoke tests into the regular smoke
tests; we just run all the tests with auth on and that way we don't
need to spin up an entire separate cluster of machines just to run
a single query against them.

We improve the error detection, and standardize the jq-to-get-config
code. The purpose of this is to try to make sure that, if we actually
hit a failure and get "null" for a host name, we report *that*
as an error, rather than running ahead and producing 20+ separate
reports that ssh failed because it couldn't find a host named null.
2022-09-09 17:10:57 -05:00
Seebs
d627ff1724 don't run commands against holder before messing with its stats
You have to start the cluster before you can refer to its holders,
because GetNode doesn't work on an unstarted cluster, but if you
actually issue any commands, those require messing with the worker
pool which wants to have access to the holder's stats.
2022-09-09 17:10:57 -05:00
Matthew Jaffee
5be85a0d47 add persistent history and combination of multi-line commands to CLI
"featurebase cli" will now save command history to
$HOME/.featurebase/cli_history by default. Additionally if a command
is entered across multiple lines, the newlines will be removed when
the command is saved in the history. Previously each line was saved
separately which was a bit annoying.
2022-09-07 13:10:29 -05:00
pokeeffe-molecula
0a73abbbfe
Add a smoke test for the sql3 endpoint (#2214)
* turned on sql endpoint in smoke test; added a test to execute a simple sql statement

* add config to both configs

* fixed not enough arraying
2022-09-07 09:34:45 -05:00
Garrison Davis
1469f4a72c
Fix UUID library version for CVE-2021-3538 (#2213)
We were using v1.2.0 of the github.com/satori/go.uuid library to
generate UUIDs for transactions if the transaction had no previous id.

That version of the library had CVE-2021-3538: "Due to insecure
randomness in the g.rand.Read function the generated UUIDs are
predictable for an attacker."

More reading can be done here:
https://pkg.go.dev/vuln/GO-2022-0244
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3538

This vulnerability was found using the new govulncheck tool which is not
currently used in our CI pipeline but might be a good candidate to
include in the future. (Like all tools like this there are caveats to
its usage and utility which can be read about below.)

Information on that tool can be found here:
https://go.dev/blog/vuln
https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck
2022-09-06 13:52:13 -06:00
pokeeffe-molecula
7c936471cc
sql3 changes (#2211)
* first cut of working (slowly) bulk insert; table valued functions and a tuple data type to support time quantums

* oversight

* filter pushdown implementation; bulk insert

* addressed some linter issues
2022-09-06 11:16:11 -05:00
Seebs
790d1bf3dc drop [postgres] config stanza
This might be breaking CI now that the postgres wire protocol support
has been dropped.
2022-09-02 11:40:37 -05:00
Seebs
2052bb01d8 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-02 11:40:37 -05:00
Seebs
5579034eb2 shorten SetValue_QuickCheck
We reuse a fragment. It might seem surprising that this works, but
the fragment code actually doesn't have a persistent bit depth at
all, it just accepts whatever bit depth you tell it to use. Cutting
out the recreation of the fragments saves some time.

We also cap bit depth at 8, instead of 62, because there's a ton
of runtime cost to testing more bit depths, but it doesn't actually
change the logic.
2022-09-02 11:40:37 -05:00
Seebs
b2e56a2bc3 reduce simultaneous memory usage a bit
Delete indexes after we're done with them from subtests so that
we don't fill up on a huge number of unrelated indexes.
2022-09-02 11:40:37 -05:00
Seebs
937be623f7 set RBF sizes smaller for test
We end up hitting race detector limits on MacOS. This should mitigate
that.
2022-09-02 11:40:37 -05:00
Seebs
84a980af6a fix silly math typo
For arbitrary mod values m, greater than zero,
	(x%m + 1) != 0
is always true

What we almost certainly meant was
	x%(m+1) == 0

which would give you all the bits in row 0, half the bits in row 1,
etcetera.

Also, we drop to doing a quarter-shard because why not.
2022-09-02 11:40:37 -05:00
Seebs
397badbccb 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-02 11:40:37 -05:00
Seebs
d81320c2ab improve post-hook behavior
We want to be able to register hooks which do cleanup, which may be
registered after the auditor cleanup check, which means that we
want LIFO order for post-hook cleanups.

We also want the test hook cleanup to be deferred, rather than
merely run after the tests are executed. Also, we have to extract
the result from running the test, then execute deferred things,
*then* call os.Exit, because os.Exit bypasses defers.
2022-09-02 11:40:37 -05:00
Seebs
474d3e0794 kill everything that tries to pass nil tx to field/view things
The "field/view will just synthesize a tx" behavior is awful and
also hides a number of fundamental flaws. We distinguish between
"we really do mean to work on a single shard here" and "we intend
to work on the whole field or view", and the latter now take
Qcx instead of Tx.

This eliminates a lot of very weird cases where we checked for
nil Tx and synthesized them, and also gets us away from
field and view taking Tx parameters when no possible Tx
can be constructed which is valid, because Tx are inherently
shard-specific at this time.
2022-09-02 11:40:37 -05:00
pokeeffe-molecula
e4a4a06af0
added /sql endpoint; implemented SHOW TABLES (#1935)
* squashed 45 commits into one :)

* tlt/sql experiment (#2035)

* Move PlanOperator to sql3/planner/types package

includes:
type PlanOperatorColumn struct
type PlanOperator interface

* Remove planner dependencies from pilosa package

The goal after this is to prevent the planner package (which doesn't exist yet)
from being imported by the pilosa package; we just want it injected into the server
in server/server.go. This is because the planner package uses pilosa types, so we need
to avoid circular dependencies.

Added ExecutionPlannerFn
Make public: pilosa.ExecOptions
Added a pilosa.Executor interface
Added a planner.types.CompilePlanner interface
Isolated the planner calls to:
- Executor.Execute()
- *API.[method]()

* Move executionplanner files into the sql3/planner package.

This required a bit of gymnastics, and there are some things around
FieldOptions which need to be addressed soon.

* Remove the hacky FieldOptions stuff I added earlier

This implementation just uses the pilosa.FieldOption functional options
provided by the API (as opposed to trying to build a FieldOptions
object.

It also changes field types to constants. These are private for now, but
if we need to make them public, we should put them in the planner/types
package.

* Implement the "scale" value from Decimal(scale)

Also, precision and scale were currently reversed in the parser. This
fixes that.

* Modify the parser to handle CACHETYPE <type> SIZE <size>

It's a little odd to me that the cache type values are Tokens, but I
guess it's ok. One thing to keep in mind is that FeatureBase expects
lowercase values, so this commit changes the parser to set the value to
the lowercase version of the type.

* Fix the /sql2 tests

This entailed a combination of commenting out or t.Skip()-ing tests
which covered code in the parser that has been commented out or removed
as not currently supported in sql3.

It also adds some coverage for the sql.Contraint stringers.

* Prevent JSON sql results from containing closing commas

This commit just re-works the existing output code to avoid inserting
closing commas (which results in invalid JSON).

* Enhance the CREATE TABLE test coverage.

In particular, ensure that the fields which get created in FeatureBase
are what we expect based on the fields defined in the CREATE TABLE
statement.

This also ensures that the TIMEQUANTUM and CACHETYPE contraints are not
provided for the same field (since those constraints are not supported
together).

* Adjust the EBNF file to indicate SIZE contraint is optional

A CACHETYPE can be provided without a SIZE. This change indicates that
SIZE is optional.

* Remove `executionplanner_` from file names (#2040)

* implementation of ALTER TABLE (sans column RENAME)

* refactored expression analysis; added more robust type checking; all unary and bin ops function on ints

* added type support for expressions; full bin/unary op support; added cast; more literal support

* cast int to all other types

* all literals (except idset, stringset & timestamp) make it thru; cast to all types with int as source now works

* implemented LIKE/NOT LIKE

* Implemented IS [NOT] NULL

* Move sql2 files into sql3/parser package (#2045)

* Move sql2 files into sql3/parser package

This also removes the sql2 package.

* Fix tests which were typing _id fields as INT intead of ID

* implemented BETWEEN, NOT BETWEEN

* Add featurebase/error package (#2046)

* Add featurebase/error package

I copied the `dax/errors` package which I am starting to use in the DAX
prototype into `featurebase/errors` in order to start using it with the
sql3 package. It's basically a wrapper around `github.com/pkg/errors`,
but it uses a customer coded error.

The sql package can define its own errors based on the
`featurebase/errors` types. Then do things like `Wrap()` and `Is()`.

* Address the linter complaints: shadowed variables, unreachable code

* implemented IN & NOT IN with expression lists

* first cut of CASE

* Fixed some errors from rebase

* updated bnf; removed unused code; tightened up error handling

* first crack at basic CLI for SQL3

Use: `featurebase cli`

Still lots to do here, but for example:

> select count(*) from tremor
+--------------+
|        COUNT |
+--------------+
| 1.158321e+06 |
+--------------+

* Iterate on the CLI (#2057)

Handle the errors.
Add an "exit" command.
Add some general formatting and white space.

Add termination character: ";" (semicolon)

This commit allows a user to provide multiple or partial SQL statements.

Example of multiple statements:
```
show tables; select * from foo;
```

Example of partial (multi-line) statements:
```
select *
from foo;
```

Don't uppercase the header values

* error refactoring; first cut of TOP; remove unused code; use log.Printf instead of fmt.Printf

* fixed a bug with QualifiedRef from refactoring; added bones of INSERT; removal of unused code; tightened up errors more; fixed failing tests

* single value list for INSERT

* Update bnf per discussion with Travis; INSERT now doing the requisite stuff

* Pat's eyes went square - nothing wrong with TOP, Pat needed to learn arrays again.

* improved some errors; fixed tests to suit

* send warnings back in the api; update CLI to display warnings

* start warning on stuff not implemented so we don't get bugged about it

* Tlt/sql experiment (#2063)

* Expresssion -> Expression

* Add SQL planner test

- adds a test to which it is easier to add tables and SQL statments
- un-exports all of the expression types
- removes the planner pointer from the expression types (it can be added
  back later if need be)

* Fix where clause on a string field

Prior to this commit, the binary expression for a where clause on a
string field was building the call by providing a range operator which
is typically used for BSI fields. This changes it to use the call.Args
for string values.

* Update planner tests to handle multiple sql for the same results

* Reorganize SQL tests

Introduce a test/helpers package and move shared MustQueryRows into that
package.

* Add a compatibility map for field types. (#2064)

This is primarily to address the fact that ID fields were previously
incompatible with INT literals.

We should probably consider introducing a custom type for FieldType
which can be used to define compatibilities.

* significantly refactored type checking

* Handle nil (NULL) values in the sql CLI. (#2067)

go-pretty panics if the interface{} field value is nil. This replaces
nil values with a "NULL" string.

* Squash some commits

fixed a still failing test

added line, col to all error messages

refactored source handling to enable table aliases

fixed some copypasta per review

warnings for order by & topn; implemented select as a source

starting to handle in (select...); added stub for optimizer

JSON-encode the sql error and warning strings (#2069)

Error strings with unencoded characters (like double quotes) were
resulting in invalid json.

got insert working; added symbol table; added concrete optimizer; added nascent NestedLoopsOperator; rewrite "where foo in (select..." as inner join

* all about the sets (#2085)

* implemented setcontains()

* implemented set literal; insert set column values; setcontains/all/any both in expr eval and pql filters

* Convert test to use latest framework. (#2086)

* fixed some comments

* removed refactored tests

Co-authored-by: Travis Turner <travis@pilosa.com>

* Add support for Decimal fields to the sql test. (#2090)

* dates (#2094)

* return dates as strings in output; tightened up decimal type checking

* return dates as strings in output; tightened up decimal type checking

* fixed failing tests after decimal changes

* can now insert decimal values

* implemented insert for timestamp data type; implemented current_date, current_timestamp constants

* fixed some failing tests

* handle date literals from strings in insert statements

* changes from feedback

* Fix pointer method error

* sql3 API interface (#2110)

* Introduce API-related interfaces: SchemaAPI, ComputeAPI

The sql3 code was relying on the pointer: *pilosa.API in order to call
API methods directly on the local node. If we want to import and use the
sql3 package in another service (the DAX queryer, for example), we need
to be able to use an implementation of an interface for those API method
calls.

This commit introduces two interfaces, both automatically implemented by
pilosa.API:
- SchemaAPI
- ComputeAPI

* Convert sql3 code to use IndexInfo instead of Index

The sql3 code was relying on a *pilosa.Index and its methods to get
general information like index and field name, type, etc. This commit
converts everything to use a *pilosa.IndexInfo instead.

This allows us to modify the SchemaAPI interface to also return
IndexInfo instead of Index, which will be a lot easier to implement in a
non-pilosa package (like DAX); creating a *pilosa.Index requires
providing things like data directory paths and holders, which are not
necessary for these use cases.

* Unary and Binary Ops R US plus CAST (#2111)

* implemented string literal for timestamp epoch

* fixed failing test

* fixed the failing test again

* refactored tests; implemented unary op tests for all datatypes; implemented binop tests for int/int, int/id, int/decimal & ID/int

* implemented all binary ops for INT & all other types, ID & all other types

* implemented binary ops for DECIMAL types & all other types

* added STRING & BOOL to various tests; implemented all remaining binOp tests

* fix up some stuff after rebasing

* refactored test defs into multiple files; implemented CAST for every datatype

* added tests for like/not like

* addressed review feedback

* addressed type review feedback

* tightened up IS [NOT] NULL behavior plus tests (#2118)

* tightened up IS [NOT] NULL behavior plus tests

* BETWEEN/NOT BETWEEN with all data types

* addressed review feedback

* Handle negative integers in column min/max constraints (#2120)

This commit parses the min/max contraint as an expression, as opposed to
an int literal, so that negative values are treated as Unary
expressions.

There currently isn't support for min/max constraints on `decimal`
fiels, so for now this change only expects +/- integer values.

* Implement the CREATE TABLE keypartitions logic (#2123)

* Execution time, IN/NOT IN & multiple aggregates (#2124)

* added display of execution time

* IN/NOT IN tests for all data types

* fixed date parsing

* removed duplicative tests

* refactoring aggregates

* suport multiple aggregates

* Address review feedback

* final round of feedback

* Add method SchemaAPI.CreateIndexAndFields() (#2127)

In order to support a CREATE TABLE statement as a single command, this
commit alters the SchemaAPI interface to contain a single method which
handles both the index and its fields. It also updates the sql3 code to
use this interface instead of CreateIndex() and CreateField()
indepedently.

* Symbol Handling (Again) (#2129)

* Refactored symbol handling in the planner; re-instated the select as source tests

* removed commented out code

* addressing review feedback

* Move hard-coded _id field out of planner and into interface implementation (#2130)

This commit moves the hard-coded addition of the `_id` field from the
planner to the SchemaAPI.IndexInfo() implementation method.

NOTE: If anything was expecting SchemaAPI.Schema() to also return the
`_id` field as part of its field list in each table, then it would not
be there because the `_id` field is only added in the IndexInfo() method
for now. Currently that's not a problem because nothing is expecting the
`_id` field for `Schema()`.

* Multiple aggregates, all aggregates stand alone and in GROUP BY (#2132)

* handle multiple aggregates in group by queries

* added handling for avg() aggregate both stand alone and in group by

* tightened up sum & avg outside of group by

* added min, max & percentile

* added warnings

* Make MaterializedRowSet implement the PlanOperator interface. (#2133)

This commit refactors the PQLMultiGroupByOperator to have a PlanOperator
as its output. Then, when it initializes, it sets up a
MaterializedRowSet and populates that with the values from the multiple
group by operations.

* added explicit min/max pql operators

* saved a file I forgot to save

* per review

* Un-indent some if/else nesting (#2136)

Co-authored-by: Travis Turner <travis@pilosa.com>

* Add optional `name` argument to test structs.

This commit adds the `name` argument to `tableTest` and `sqlTest` so
that a test can be optionally named. This allows a developer to more
easily run/identify a particular test by name.

* Inbuilt functions (redux) (#2141)

* set functions type parameter type checking

* implemented datepart

* include SQL3 type in SHOW COLUMNS output

* fixed select as source; failing SHOW COLUMNS test

* select in select list

* dump output columns; handle optimization for select list subqueries

* make it an error to return multiple rows for a select list subquery

* added description

* contants and test coverage for datepart function

* SQL3 Refactor-palooza (#2182)

* removed unneeded IsAggregate()

* first cut of working nested loops operator aka INNER JOIN

* remove selectListItemPlanExpression

* added some warnings

* all the tests are passing again!

* addressed some linter complaints

* added basic order by

* bug fixes; added 'or replace'/'replace' to insert

* for insert references should return appropriately

* added back ability to use subquery singleton expressions

* removed dead code; fixed test

* json-able plan, Schema() plus refactoring

* fixed dumb code

* add some tests for time quantum behavior

* Code cleanup during review. Also fixed INSERT to keyed table bug.

This commit contains a lot of minor adjustments made during code review.

It also contains a bug fix that was preventing INSERT into a keyed table
(i.e. _id type STRING) from working.

Co-authored-by: Travis Turner <travis@molecula.com>

* Fix expected min/max on timestamp column test (decimal field)

I don't know why this changed, but presumably something to do with
decimal related work that happened on master.

* Fix compile problem after rebase

* review feedback

Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
Co-authored-by: Travis Turner <travis@pilosa.com>
Co-authored-by: Travis Turner <travis@molecula.com>
Co-authored-by: Fletcher Haynes <fletcher@capitalprawn.com>
2022-08-31 13:01:05 -07:00
Hoang Pham
650b7eaa45 FB-1627 - Added backup/restore tar. Purpose: for cloud team to backup and restore directly through stdout, stdin 2022-08-29 11:03:10 -05:00
Garrison Davis
6562b60340
Fix idk Version and idk BuildTime (#2205)
When we merged idk into featurebase, we didn't change the import path in
the Makefile to point to the correct go path
2022-08-25 17:43:13 -06:00
Garrison Davis
123b20d2f9
Upgrade Go to 1.19 (#2204)
Upgrade Go to 1.19

* Use go install to install statik for CI/CD

* Switch from stretch to buster for idk

The stretch release doesn't exist anymore for go 1.19 docker images.

buster is a newer version of Debian anyway (v10 vs v9)

Co-authored-by: Fletcher Haynes <fletcher.haynes@molecula.com>
2022-08-25 14:54:14 -06:00
Seebs
f03df56844 avoid insanely strange crash
So, nShards used to be 10. If you run a complete test, with go
test -race, and you have the sample input for the unrelated
TestImportMutexSampleData configured to use 64K bit density and 2K
rows, everything is fine. If you run a partial test, everything is
fine. If you run a complete test with -race, but you skip
TestImportMutexSampleData, or reduce either the bit density or the
row count, you get a very strange panic where the go panic handler
panics trying to report what happened so we don't get a valid stack
dump. On Macs. This is as much as I could debug it after about 6
hours. Since there's no special reason to think we need all 10
shards, and 9 still tests the behavior, we're leaving this one a
mystery.
2022-08-25 15:00:48 -05:00
Seebs
f3c164c483 don't rerun comparison pointlessly
The comment says "convert to each type and compare", but it
doesn't convert, it just compares the given container result to
three different forms of the same result. That's neat for testing
BitwiseEqual but doesn't actually give us more information, and
it takes nearly 3x as long.
2022-08-25 15:00:48 -05:00
Seebs
edbb2d3e1e Run slightly fewer set commands
We don't need all that many random set commands to get some coverage
for them.
2022-08-25 15:00:48 -05:00
Seebs
1f754dd998 Reduce amount of bit setting in mutex sample data
The mutex sample data test should still hit bugs with smaller
N and is very expensive for larger/denser data sets.
2022-08-25 15:00:48 -05:00
Seebs
33bd22a7cf parallelize some tests
These tests seem likely to be safe to run together, so let's.
2022-08-25 15:00:48 -05:00
Seebs
ebef51daa0 smallify Quick checks
Quick checks aren't super helpful, but they can test random stuff
a bit, so let's keep them, but make them smaller. Also, let's cram
the random selections into the first quarter of a shard so we see
more container updates to fewer containers because that's probably
more interesting.
2022-08-25 15:00:48 -05:00
Seebs
525412a5d8 rework Tx_Remove test to be much, much, faster
don't add/remove two million bits one at a time. instead, insert
small array containers, make them larger, replace them with bitmaps,
and so on. In short, we still create containers and change their
sizes in interesting ways, but we do it thousands of bits at a time.
This reduces runtime with -race from around 10-20 minutes to a second
or so.

We drop the "PartialContiguous" test because it was actually just
identical to PartialNoncontiguous, so far as I can tell, and not
really interesting.
2022-08-25 15:00:48 -05:00
Seebs
3c9a338d09 log errors we retry from, reuse retryablehttp client more consistently
We make clients pass in a context which has an associated
data structure which can be used to annotate errors we've encountered
inside retryablehttp. You might ask why we do this instead of
just giving retryablehttp a logger that isn't nopLogger; the answer
is that retryablehttp's logging is too spammy to use.

So we create a context, and then pass that in for requests, so that
when we check to see whether we should be retrying, we can log
the errors we encounter, so if we encounter errors we can log
something specific instead of "gave up after 5 retries".

We also make a second retryable client that would forward
authentication, and reuse that, rather than making a new client
for every call that needs to forward authentication. This allows
us to avoid the problem where that inner client wasn't picking
up the timeout settings we'd applied to the parent.

We log errors with Errorf if we actually failed entirely to do the
request, we log them with Infof if there's errors but the request
ultimately succeeds. We also try to log part of the response body
when there is one, but there wasn't an error.

If there's no response, we produce a spurious 500 and a message
saying that we produced it.
2022-08-25 10:11:50 -05:00
hphamMolecula
a2d02ffc57
FB-1337 - UI - fixes for regex backtracking vulnerabilities (#2187) 2022-08-24 15:37:55 -05:00
Seebs
317526cc09 add "only" clauses to IDK tests
The IDK tests should be run only when there's changes in the IDK
or client directories.

Also the shard transactional test should be run ever.

The "optional: true" flag is a fascinating quirk allowing you to
express that, *if* a job exists, we should wait for it, but if the
job doesn't exist, that's also acceptable.
2022-08-22 11:48:07 -05:00
Seebs
f066fcb33c Use socket instead of TCP for etcd config
When we make dummy test servers, we should make them using sockets
for etcd rather than TCP ports so we don't run into problems like
the test always failing if anything else is on that port already,
which it can totally legitimately be. For instance, if you ran
an existing featurebase server, and then tried "go test" in the
server directory, this would fail.
2022-08-22 11:48:07 -05:00
Seebs
36a4fb2cb7 skip IDK in "make test"
We want "make test" to run in a reasonable amount of time and
actually work, the IDK tests are full of tests that only run in
a specialized docker environment with things like hosts named
pilosa and kafka and such.
2022-08-22 11:48:07 -05:00
rachithrr
3d04b38398
Yaml invalid error (#2199)
Yaml invalid error. The rules of a job has to be in agreement with its prerequisites.
2022-08-19 16:49:58 -05:00
rachithrr
3e42fc7d9f
WIP: Sort extract columns by a field (#2193)
* FB-1251: Add ability to sort Extract queries by some field

There is a sort call which takes a row call and the field, and
based on the field type, the corresponding rows are read. both key and
value are stored in RowKV{}. The value is stored since its required to
merge data from shards. values are sorted in each shard and these sorted
listes are merged in the reduce.
sort-desc flag is sent to comparator to decide the sorting order. ok
flag is added to the compare function to track any error in the
sort.Slice anonymous function
Sorting over set field was removed, since there would be multiple values
for each ids and there would be no right sorting order there.
2022-08-19 13:29:17 -05:00
Garrison Davis
52e4dbb695
Add caching to go jobs (#2181)
The caching is done at the branch level.
2022-08-18 14:31:35 -06:00
Garrison Davis
9eb6b3ac3f
Fix idk package_docker_all CI job (#2196)
Before, we were building docker images for IDK for each of the four
linux/darwin amd64/arm64 platfrom/arch combinations, which didn't make
sense. If we want to later build docker images for linux/arm64, we can
add that later.

I also cleaned up the Dockerfile for IDK to minimize creation of excess
layers (by &&-ing RUN commands), and made apt quieter to cut back some
of the noise.
2022-08-18 13:52:04 -06:00
Garrison Davis
11fe9f0cad
Fix gosec-sast job (#2194)
We need to install base gosec tool and then the gitlab version to convert the gosec
json to the gl-sast-report.json that GitLab expects.

This lets us see the 'Security' tab under pipelines (and under the default branch
after this change is merged).

I chose to pin both of the versions of the tools to avoid any dependencies changing.
This could be an issue, but both repos are largely frozen.
2022-08-17 12:43:46 -06:00
CLoZengineer
a183357d65
chore(community): adds code of conduct (#2195)
Co-authored-by: Christopher Lowenthal <christopher.lowenthal@molecula.com>
2022-08-17 12:30:22 -04:00
Garrison Davis
584c1797cf
Use CI_COMMIT_REF_SLUG to tag Docker images (#2191)
We're using this because it's a builtin env variable that comes
with GitLab, and it fixes one of the annoying things about Docker
tags (e.g., you can't use all of the allowed characters in
Git branches).

One issue that I've seen a few times, is branches with either
capital letters (which was recently broken), or using the '/'
character.

This PR makes it so we always use the CI_COMMIT_REF_SLUG
when making or referencing images so that it is always consistent.

Note: this might make it slightly harder to intuit what the correct
Docker image to make (if you wanted to use the one built by CI rather
than locally). This trade off doesn't seem too hard to overcome.
2022-08-16 13:00:37 -06:00
Travis Turner
cddd9871af
Distinguish between three copies of fakeidp service (#2192)
There are currently three copies of a package called `fakeidp` in the
featurebase repo:

- ./idk/fakeidp/go.mod
- ./internal/clustertests/fakeidp/go.mod
- ./qa/fakeidp/go.mod

All three have a `go.mod` file. While this is supported under golang's
new Workspace support, what's not supported is that the modules share
the same name (in this case "fakeidp"). This commit is a sort of
temporary fix which renames the module for two of the instances. This
prevents, for example, VSCode with workspace support enabled, from
barfing.

By the way, one can enable VSCode workspace support with the following
setting:

```
// gopls
"gopls": {
    "build.experimentalWorkspaceModule": true
}
```

Also...

This commit fixes the `make testv` target. It's probably not used
anywhere (which I'm assuming because it was broken), but it's a handle
target, so now it will list and run tests against all packages found in
the repo, including the root package.
2022-08-16 09:13:11 -05:00
wmanongdo
baab212bb1
[CLOUD-934] Optionally broadcast IDK Kinesis errors/panics to externa… (#2185)
* [CLOUD-934] Optionally broadcast IDK Kinesis errors/panics to external storage

- Add a minor public method `idk.Main.SetLog` to allow setting the logger instance
  after initialization.
- Add a Logger implementation that captures recoverable errors and panics
  and pushes to an external store. Meant to decorate an existing Logger
  instance and always delegate to its implementation. Decoration happens
  when all AWS resources are initialized. Before then, the wrapped Logger
  implementation is used.
- If `--error-queue-name/CONSUMER_ERROR_QUEUE_NAME` specified, use an
  ErrorStreamLogger to push errors and panics to an SQS queue with that name.
  Omission of the option preserves current behavior.
- Parse sink ID from the `--stream-name/CONSUMER_STREAM_NAME` expecting the form
  'PREFIX'-VALID_UUID. If the sink UUID is invalid, emit a warning that errors/panics
  will not be written to an SQS queue but will still be logged using the decorated
  Logger instance.
- The inability to push to an SQS queue leads to warnings being emitted to notify
  ECS that no queue will be written to and is NOT a hard error.
- Add SQS interface mock for unit testing.
- Add IDK make targets for generating mock interfaces.

* [CLOUD-934] Execute go mod tidy and go fmt to pass CI/CD checks

* [CLOUD-934] Remove extraneous Makefile in idk/kinesis and fix install-mock-generator target

* [CLOUD-934] Add godocs to exported types and functions

* [CLOUD-934] Changed warning to not sound so ominous and update associated unit test

* [CLOUD-934] Unblock CI/CD at the IDK test stage
2022-08-12 17:59:56 -05:00
souhailanoor
39def696c5
FB-1618: Fix code smells due to unifying IDK and Featurebase (#2184)
* create constants for duplicates to resolve code smells

* refactored duplicated code for extract(rows))

* additional refactoring

* refactor test

* rename to match reg exp

* fixed naming

* fixed naming, removed duplicated string

* fixed index names

* fixed bug introduced in earlier commit

* create delete index method and refactor if statement

* refactored file to reduce complexity

* fix go fmt error

* fixed bug introduced in last commit

* address reviewer's comments

* remove trailing colon and spaces
2022-08-12 17:00:29 -05:00
hphamMolecula
985a70b14e
FB-1601 - Put a link to the cloud SaaS page in the admin UI (#2189) 2022-08-11 14:55:50 -07:00
Samir Patel
3c2ef484bd
[FB-1621] account for token expiration as float and int (#2188)
* account token expiration as float and int

* update tests
2022-08-10 17:26:10 -05:00
tgruben
7cfa516f74
[FB-1617] Commit Messages out of order (#2180)
* commiting partition highmark offset only; 
* protected spool access with lock
2022-08-08 14:41:22 -05:00
Samir Patel
3681feeeb2
[FB-1024 FB-1590] Increase timerange (un-revert) (#2174)
previously we allowed users to specify a granularity for timestamp
e.g. seconds, milli, micro, nano
however we converted everything to nano before we stored it.
This reduced the allowed range for all time units to what
was allowed by timestamp. For example, with second granularity
you can represent billions of years within the capacity of
int64 but with nano its somewhere b/w 100-200 years.

So now, for timeunits of seconds, milli, and micro the range
is year 0001 - 9999. These limits come from what Go
supports.

So this uses unit specific function to translate
timestamps to values and vice versa to increase
the time range.

In the process of increasing the range for timestamp and subsequent
testing, I found and addressed a few bugs:
- min/max queries were not using timestamp specific comparators so
  added that.
- Values from Import/ingest come to FB as relative values to epoch
    whereas other BSI fields come as actual values and then
    becomes relative to their respective bases within FB. so some
    specific handling of that was added.
- However! Set queries use timestamp strings which are, of course,
    the actual value they designate. So they have to become
    relative.
- When bitdepth is 0, Min/maxUnsigned functions did not run
resulting in a count of 0 when there
was an actual value that was 0.

Also, this removes (now) dead code and updates/adds tests.
2022-08-04 15:20:45 -07:00
tgruben
7a53e1e830
update to 1.9.1;make rm safe (#2175) 2022-08-02 15:09:20 -05:00
reesporte
b9865ee99a add row-col-mode to featurebase import
most types are imported in the format `<row>,<col>`, but ints and decimals
aren't. with this new flag, ints and decimals are imported using the
`<row>,<col>` format, instead of `<col>,<row>`.
2022-08-02 12:12:53 -05:00
tgruben
177db2e2b5
removed invalid state (#2173) 2022-08-01 12:47:17 -05:00