Commit Graph

91 Commits

Author SHA1 Message Date
Nik Everett 1ea3f5175a Fix build
Original commit: elastic/x-pack-elasticsearch@474e5e7a9a
2017-08-23 09:17:39 -04:00
Costin Leau 18dccbc668 Consolidate spec testing
Remove some duplicated methods, add some templating plus logging of
ES resultset (for easier debugging)
Rename debug test for CSV plus add one for Sql spec

Original commit: elastic/x-pack-elasticsearch@d2c46a2ed2
2017-08-22 23:24:01 +03:00
Igor Motov 4c597a2944 SQL: Add support for explicit types in CsvSpecTests (elastic/x-pack-elasticsearch#2306)
Adds support for specifying column types in CSV Spec tests.

Original commit: elastic/x-pack-elasticsearch@4d5622f298
2017-08-18 12:12:06 -04:00
Igor Motov 65ff793a19 SQL: Rename DebugCsvSpec to match test naming convention
Original commit: elastic/x-pack-elasticsearch@7ad2dba5ec
2017-08-17 16:25:11 -04:00
Costin Leau 8605263385 Fix overlapping getters in Function vs AggFunction
Original commit: elastic/x-pack-elasticsearch@f208936b72
2017-08-17 17:29:16 +03:00
Costin Leau 1471c8ab7f Update constructor for NumericAggregate classes
Original commit: elastic/x-pack-elasticsearch@732742083b
2017-08-17 16:20:44 +03:00
Costin Leau 2c830bdff2 Add support for percentile and percentile ranks aggs
Original commit: elastic/x-pack-elasticsearch@dc443ed465
2017-08-16 12:18:20 +03:00
Igor Motov 4242cc7370 SQL: Tests cleanup (elastic/x-pack-elasticsearch#2252)
Move Transport Request/Response tests to sql server project, remove unused ProtoTests.

Original commit: elastic/x-pack-elasticsearch@2ad0f3bde2
2017-08-14 17:23:57 -04:00
Nik Everett f7d526036e Un-AwaitsFix SQL's jdbc integration tests (elastic/x-pack-elasticsearch#2217)
Most tests worked fine. The datetime tests are broken for some time
zones. The csv tests were broken because they accepted the default
fetch size which looks like it is broken.

Original commit: elastic/x-pack-elasticsearch@e034c2f102
2017-08-09 08:33:14 -04:00
Nik Everett 85937c6e78 Fix SQL's DatabaseMetaData (elastic/x-pack-elasticsearch#2214)
It was failing because it was missing config needed to properly
handle time zones.

Original commit: elastic/x-pack-elasticsearch@1166ea7475
2017-08-08 17:48:03 -04:00
Nik Everett 570b66638e Add test for index with two types (elastic/x-pack-elasticsearch#2194)
Adds a test that shows *how* SQL fails to address an index with two types
to the full cluster restart tests. Because we're writing this code
against 7.0 don't actually execute the test, but we will execute it when
we merge to 6.x and it *should* work.

Original commit: elastic/x-pack-elasticsearch@b536e9a142
2017-08-08 13:32:13 -04:00
Nik Everett f241512e33 SQL support for field level security (elastic/x-pack-elasticsearch#2162)
This adds support for field level security to SQL by creating a new type of flow for securing requests that look like sql requests. `AuthorizationService` verifies that the user can execute the request but doesn't check the indices in the request because they are not yet ready. Instead, it adds a `BiFunction` to the context that can be used to check permissions for an index while servicing the request. This allows requests to cooperatively secure themselves. SQL does this by implementing filtering on top of its `Catalog` abstraction and backing that filtering with security's filters. This minimizes the touch points between security and SQL.

Stuff I'd like to do in followups:

What doesn't work at all still:
1. `SHOW TABLES` is still totally unsecured
2. `DESCRIBE TABLE` is still totally unsecured
3. JDBC's metadata APIs are still totally unsecured

What kind of works but not well:
1. The audit trail doesn't show the index being authorized for SQL.

Original commit: elastic/x-pack-elasticsearch@86f88ba2f5
2017-08-04 15:27:27 -04:00
Nik Everett 4f42de6b1a Fix as many busted tests as I can
Original commit: elastic/x-pack-elasticsearch@5ec24f6818
2017-08-03 17:27:56 -04:00
Costin Leau 0675d08f25 Remove support for indices with multiple types
Indices discovery actively ignores indices with more than one type.
However queries made such indices throw an exception (assuming the user
by mistake or not, selects such an index).

Original commit: elastic/x-pack-elasticsearch@16855c7b8f
2017-08-03 22:05:59 +03:00
Costin Leau 38ea150f17 Expand SQL client support
- SSL (tested)
- Basic auth
- Proxying (HTTP and SOCKS)

Original commit: elastic/x-pack-elasticsearch@3abc49897e
2017-08-03 15:36:03 +03:00
Nik Everett 89071f1807 Remove a dependency cycle in the build (elastic/x-pack-elasticsearch#2122)
This is a hack to remove a dependency cycle I added in elastic/x-pack-elasticsearch#2109. I think
it'd be cleaner to remove the cycle by making sql its own plugin that
doesn't depend on the rest of x-pack-elasticsearch but is still
included within x-pack-elasticsearch. But that is a broader change.

Original commit: elastic/x-pack-elasticsearch@47b7d69d80
2017-08-01 10:29:49 -04:00
Nik Everett 2ac45f18fe Remove leftover in build (elastic/x-pack-elasticsearch#2099)
I had added this to help VersionTests.java identify when it was running
in gradle so it could be sure that it got the real Version information
but even running in gradle doesn't give the real version information
because it runs against a build directory instead of a jar. And the jar
is all that has the version information because the version information
is read from the manifest.

Original commit: elastic/x-pack-elasticsearch@3acbd01433
2017-07-27 10:01:09 -04:00
Igor Motov 2c8f96efc7 Sql should run in ci (elastic/x-pack-elasticsearch#2080)
Fixes several minor issue to enable sql branch to run in CI.

Original commit: elastic/x-pack-elasticsearch@b479cff92c
2017-07-25 14:59:50 -04:00
Nik Everett dd29035e66 Use manifest file for version info
This removes a hack I'd left in the build file that hard coded the
hash of jdbc driver. Now we dig the version information out of the
MANIFEST.MF file that is written during the jar process for all
projects in the Elasticsearch build.

Original commit: elastic/x-pack-elasticsearch@fa01cc6fb3
2017-07-25 13:30:35 -04:00
Nik Everett a8a6191428 Handle core's shading and fix some licenses
Original commit: elastic/x-pack-elasticsearch@962dd2c8b4
2017-07-25 09:41:52 -04:00
Costin Leau 04c9427596 Pass jdbc fetch size to the scroller
Original commit: elastic/x-pack-elasticsearch@2309a43980
2017-07-21 00:11:01 +03:00
Costin Leau 76b429bfe2 Introduce SqlSettings for handling per-client configuration
To avoid leaking client information across the entire code-base, client
settings like TimeZone or pagination are stored in
SqlSession>SqlSettings which are available as a ThreadLocal (during
analysis) so that components that need them, can pick them up.

Since ES internally uses Joda, the date/time functionality relies on Joda,
whenever possible to match the behavior.

Original commit: elastic/x-pack-elasticsearch@20f41e2bb3
2017-07-20 19:28:04 +03:00
Costin Leau 8acacc4f7d Add random fetchSize
Original commit: elastic/x-pack-elasticsearch@1f8197b04f
2017-07-18 23:15:40 +03:00
Costin Leau f33ae72712 Minor polishing
Make JDBC and CLI consistent with the rest of the plugin
Replace ResultPage with an interface

Original commit: elastic/x-pack-elasticsearch@c62249cc2e
2017-07-18 18:41:23 +03:00
Nik Everett cf29dea577 Huge protocol refactor
Too big. Sorry. Some good things though:
1. Share some code between CLI and JDBC. Probably a good thing
at this point, better as we go on, I think.
2. Add round trip tests for all of proto.
3. Remove the `data` member from `QueryInitResponse` and
`QueryPageResponse` so we response serialization is consistent with
everything else.

Original commit: elastic/x-pack-elasticsearch@c6940a32ed
2017-07-12 17:32:13 -04:00
Nik Everett 3d70d7b64e Remove some checkstyle suppressions
Original commit: elastic/x-pack-elasticsearch@a1d89e2916
2017-07-10 12:24:47 -04:00
Nik Everett f6fad00765 `cli`'s `gradle run` works!
Including proper tty support!

Original commit: elastic/x-pack-elasticsearch@a780a99d1b
2017-07-07 10:32:23 -04:00
Nik Everett edcc87e30e `gradle check -xforbiddenPatterns` passes!
Hurray! Now we just have to keep it that way!

Original commit: elastic/x-pack-elasticsearch@98b8ede44e
2017-07-06 16:24:19 -04:00
Nik Everett 527541a66e More build fixes
* A unit test for cli
* Licenses for cli
* Remove licenses for protos (no more deps)
* `SHOW TABLES` returns results in order (makes testing easier)
* Clean up embedded jdbc server
* Wire up embedded cli server

Original commit: elastic/x-pack-elasticsearch@b98aaf446b
2017-07-06 14:37:09 -04:00
Nik Everett bc2f0fe7ff Get jdbc tests passing
`gradle check -xforbiddenPatterns` now passes in jdbc.

This makes running the embedded HTTP server slightly more difficult,
you now have to add the following to your jvm arguments.
```
-ea -Dtests.rest.cluster=localhost:9200 -Dtests.embed.sql=true -Dtests.security.manager=false
```

Depending on your environment the embedded jdbc connection may give
spurious failures that look like:
```
org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcException: RemoteTransportException[[node-0][127.0.0.1:9300][indices:data/read/search]]; nested: SearchPhaseExecutionException[]; nested: GeneralScriptException[Failed to compile inline script [( params.a0 > params.v0 ) && ( params.a1 > params.v1 )] using lang [painless]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting];
...
Caused by: Failed to execute phase [fetch],
..
Caused by: GeneralScriptException[Failed to compile inline script [( params.a0 > params.v0 ) && ( params.a1 > params.v1 )] using lang [painless]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting];
...
Caused by: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting]
```

`gradle check` works around this by setting `script.max_compilations_per_minute`
to `1000`.

Another change is that we no longer support loading the test data by
uncommenting some code. Instead we load the test data into Elaticsearch
before the first test and we deleted it after the last test. This is
so that tests that required different test data can interoperate with
eachother. The spec tests all use the same test data but the metadata
tests do not.

Original commit: elastic/x-pack-elasticsearch@8b8f684ac1
2017-07-06 10:24:59 -04:00
Nik Everett 18bc094dbc Remove LocalEsCluster
We aren't using it anymore.

Original commit: elastic/x-pack-elasticsearch@67f47c4f11
2017-07-05 08:21:35 -04:00
Costin Leau 12e12f7a94 Improve exception reporting
Add the source spec in the error stacktrace

Original commit: elastic/x-pack-elasticsearch@bc7ed6ac60
2017-07-04 19:25:03 +03:00
Costin Leau 6f670c8d8e Testing fixes
- simplify handling of timezone in H2
- fix leaking threadpool in HttpServer
- update Csv tests
- keep the dates as long in internal Page

Original commit: elastic/x-pack-elasticsearch@43a804607f
2017-07-04 19:05:09 +03:00
Costin Leau 83d73c9b3a More polishing
Original commit: elastic/x-pack-elasticsearch@043edf250b
2017-07-04 00:41:16 +03:00
Costin Leau 405b4a4166 Update test dataset name
Original commit: elastic/x-pack-elasticsearch@49951836c1
2017-07-04 00:00:11 +03:00
Costin Leau 3eb1258b0d Add to CSV infra plus some refactoring of the JDBC one
Original commit: elastic/x-pack-elasticsearch@3e002c91c2
2017-07-03 21:01:29 +03:00
Costin Leau bc9c9a9151 Expanding the JDBC testing framework
Original commit: elastic/x-pack-elasticsearch@cc31f7b6a9
2017-07-01 17:20:48 +03:00
Nik Everett 6de905c2e8 Enable more tests
And remove extra file

Original commit: elastic/x-pack-elasticsearch@aade36e030
2017-06-30 16:43:37 -04:00
Nik Everett 336980ec28 Add time zone support to the connection
Flows time zones through the `QueryInitRequest` and into the
`ExpressionBuilder` which attaches the time zones to date/time
expressions. Modifies the code that generates date aggs,
scripts, and extracts results to use the time zones.

Original commit: elastic/x-pack-elasticsearch@d6682580d1
2017-06-30 16:43:37 -04:00
Costin Leau be2153851c Synch more functionality
Original commit: elastic/x-pack-elasticsearch@093c275b85
2017-06-30 20:41:47 +03:00
Nik Everett 0e8ef06947 Move sql's server stuff into :x-pack-elasticsearch:sql:server
This should make it easier to run stuff for just sql.

Original commit: elastic/x-pack-elasticsearch@d68465edb0
2017-06-29 14:31:23 -04:00