SQL: Move IT tests sql plugin project

Original commit: elastic/x-pack-elasticsearch@c7b59f05a5
This commit is contained in:
Igor Motov 2018-01-22 16:52:16 -05:00
parent 6330209e7d
commit ae55f506ca
13 changed files with 56 additions and 45 deletions

View File

@ -16,7 +16,7 @@ es_meta_plugin {
name = 'x-pack'
description = 'Elasticsearch Expanded Pack Plugin'
plugins = ['core', 'deprecation', 'graph', 'logstash',
'ml', 'monitoring', 'security', 'upgrade', 'watcher']
'ml', 'monitoring', 'security', 'upgrade', 'watcher', 'sql']
}
ext.expansions = [
@ -155,5 +155,6 @@ run {
setting 'xpack.security.enabled', 'true'
setting 'xpack.monitoring.enabled', 'true'
setting 'xpack.watcher.enabled', 'true'
setting 'xpack.sql.enabled', 'true'
keystoreSetting 'bootstrap.password', 'password'
}

View File

@ -26,6 +26,7 @@ dependencies {
provided project(path: ':plugins:transport-nio', configuration: 'runtime')
testCompile project(path: ':x-pack-elasticsearch:plugin:monitoring')
testCompile project(path: ':x-pack-elasticsearch:plugin:sql:sql-proto')
testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts')

View File

@ -64,11 +64,6 @@ import org.elasticsearch.xpack.security.user.SystemUser;
import org.elasticsearch.xpack.security.user.User;
import org.elasticsearch.xpack.security.user.XPackSecurityUser;
import org.elasticsearch.xpack.security.user.XPackUser;
import org.elasticsearch.xpack.sql.plugin.SqlQueryAction;
import org.elasticsearch.xpack.sql.plugin.SqlClearCursorAction;
import org.elasticsearch.xpack.sql.plugin.SqlListColumnsAction;
import org.elasticsearch.xpack.sql.plugin.SqlListTablesAction;
import org.elasticsearch.xpack.sql.plugin.SqlTranslateAction;
import java.util.Arrays;
import java.util.Collections;
@ -483,10 +478,10 @@ public class AuthorizationService extends AbstractComponent {
action.equals("indices:data/read/msearch/template") ||
action.equals("indices:data/read/search/template") ||
action.equals("indices:data/write/reindex") ||
action.equals(SqlQueryAction.NAME) ||
action.equals(SqlTranslateAction.NAME) ||
action.equals(SqlListTablesAction.NAME) ||
action.equals(SqlListColumnsAction.NAME) ;
action.equals("indices:data/read/sql") ||
action.equals("indices:data/read/sql/translate") ||
action.equals("indices:admin/sql/tables") ||
action.equals("indices:admin/sql/columns") ;
}
private static boolean isTranslatedToBulkAction(String action) {
@ -505,7 +500,7 @@ public class AuthorizationService extends AbstractComponent {
action.equals(SearchTransportService.QUERY_SCROLL_ACTION_NAME) ||
action.equals(SearchTransportService.FREE_CONTEXT_SCROLL_ACTION_NAME) ||
action.equals(ClearScrollAction.NAME) ||
action.equals(SqlClearCursorAction.NAME) ||
action.equals("indices:data/read/sql/close_cursor") ||
action.equals(SearchTransportService.CLEAR_SCROLL_CONTEXTS_ACTION_NAME);
}

View File

@ -388,11 +388,11 @@ public class XPackLicenseStateTests extends ESTestCase {
}
public void testSqlAckAnyToTrialOrPlatinum() {
assertAckMesssages(XpackField.SQL, randomMode(), randomTrialOrPlatinumMode(), 0);
assertAckMesssages(XPackField.SQL, randomMode(), randomTrialOrPlatinumMode(), 0);
}
public void testSqlAckTrialOrPlatinumToNotTrialOrPlatinum() {
assertAckMesssages(XpackField.SQL, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
assertAckMesssages(XPackField.SQL, randomTrialOrPlatinumMode(), randomBasicStandardOrGold(), 1);
}
}

View File

@ -1,3 +1,5 @@
evaluationDependsOn(':x-pack-elasticsearch:plugin:core')
apply plugin: 'elasticsearch.esplugin'
esplugin {
name 'x-pack-sql'
@ -12,12 +14,20 @@ esplugin {
archivesBaseName = 'x-pack-sql'
// TODO: enable this once we have tests
integTest.enabled = false
dependencies {
provided "org.elasticsearch:elasticsearch:${version}"
compile project(':x-pack-elasticsearch:plugin:sql:sql-proto')
compile "org.elasticsearch.plugin:x-pack-core:${version}"
provided "org.elasticsearch.plugin:x-pack-core:${version}"
compile 'org.antlr:antlr4-runtime:4.5.3'
testCompile "org.elasticsearch.test:framework:${version}"
testCompile project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'testArtifacts')
testCompile project(path: ':x-pack-elasticsearch:plugin:security', configuration: 'testArtifacts')
testCompile project(path: ':modules:reindex', configuration: 'runtime')
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
}
dependencyLicenses {
@ -29,9 +39,6 @@ dependencyLicenses {
ignoreSha 'sql-proto'
}
// TODO: Should we move integrations tests here?
integTest.enabled = false
/**********************************************
* SQL Parser regeneration *
**********************************************/

View File

@ -30,6 +30,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.XPackField;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings;
import org.elasticsearch.xpack.sql.analysis.index.IndexResolver;
import org.elasticsearch.xpack.sql.execution.PlanExecutor;
@ -46,11 +47,15 @@ public class SqlPlugin extends Plugin implements ActionPlugin {
private final SqlLicenseChecker sqlLicenseChecker;
private IndexResolver indexResolver;
public SqlPlugin(boolean enabled, SqlLicenseChecker sqlLicenseChecker) {
SqlPlugin(boolean enabled, SqlLicenseChecker sqlLicenseChecker) {
this.enabled = enabled;
XPackLicenseState licenseState = XPackPlugin.getSharedLicenseState();
this.sqlLicenseChecker = new SqlLicenseChecker(
this.sqlLicenseChecker = sqlLicenseChecker;
}
public SqlPlugin(Settings settings) {
this(XPackSettings.SQL_ENABLED.get(settings), new SqlLicenseChecker(
(mode) -> {
XPackLicenseState licenseState = XPackPlugin.getSharedLicenseState();
switch (mode) {
case JDBC:
if (licenseState.isJdbcAllowed() == false) {
@ -66,7 +71,7 @@ public class SqlPlugin extends Plugin implements ActionPlugin {
throw new IllegalArgumentException("Unknown SQL mode " + mode);
}
}
);
));
}
@Override
@ -90,8 +95,9 @@ public class SqlPlugin extends Plugin implements ActionPlugin {
@Override
public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
IndexNameExpressionResolver indexNameExpressionResolver, Supplier<DiscoveryNodes> nodesInCluster) {
ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings,
SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster) {
if (false == enabled) {
return emptyList();

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.analysis.common.CommonAnalysisPlugin;
import org.elasticsearch.common.settings.Settings;
@ -13,7 +13,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.util.Arrays;
import java.util.Collection;
@ -33,7 +32,7 @@ public abstract class AbstractSqlIntegTestCase extends ESIntegTestCase {
settings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
settings.put(XPackSettings.GRAPH_ENABLED.getKey(), false);
settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false);
settings.put(MachineLearning.AUTODETECT_PROCESS.getKey(), false);
settings.put("xpack.ml.autodetect_process", false);
return settings.build();
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.WriteRequest;
@ -17,6 +17,7 @@ import org.elasticsearch.xpack.sql.plugin.SqlListTablesAction;
import org.elasticsearch.xpack.sql.plugin.SqlListTablesResponse;
import org.elasticsearch.xpack.sql.plugin.SqlQueryAction;
import org.elasticsearch.xpack.sql.plugin.SqlQueryResponse;
import org.hamcrest.Matchers;
import java.io.IOException;
import java.sql.JDBCType;
@ -98,7 +99,7 @@ public class SqlActionIT extends AbstractSqlIntegTestCase {
.indexPattern("bar").columnPattern("").mode(Mode.JDBC).get();
List<MetaColumnInfo> columns = response.getColumns();
assertThat(columns, hasSize(2));
assertThat(columns, contains(
assertThat(columns, Matchers.contains(
new MetaColumnInfo("bar", "int_field", "integer", JDBCType.INTEGER, 10, 1),
new MetaColumnInfo("bar", "str_field", "text", JDBCType.VARCHAR, Integer.MAX_VALUE, 2)
));
@ -107,7 +108,7 @@ public class SqlActionIT extends AbstractSqlIntegTestCase {
.indexPattern("bar").columnPattern("").mode(Mode.PLAIN).get();
columns = response.getColumns();
assertThat(columns, hasSize(2));
assertThat(columns, contains(
assertThat(columns, Matchers.contains(
new MetaColumnInfo("bar", "int_field", "integer", null, 0, 1),
new MetaColumnInfo("bar", "str_field", "text", null, 0, 2)
));

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequest;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.XPackSettings;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.index.IndexRequest;
@ -17,6 +17,7 @@ import org.elasticsearch.license.License.OperationMode;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.elasticsearch.transport.Netty4Plugin;
import org.elasticsearch.xpack.sql.plugin.SqlListColumnsAction;
import org.elasticsearch.xpack.sql.plugin.SqlListColumnsResponse;
@ -35,7 +36,6 @@ import java.util.Locale;
import static org.elasticsearch.license.XPackLicenseStateTests.randomBasicStandardOrGold;
import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialBasicStandardGoldOrPlatinumMode;
import static org.elasticsearch.license.XPackLicenseStateTests.randomTrialOrPlatinumMode;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
@ -191,7 +191,7 @@ public class SqlLicenseIT extends AbstractLicensesIntegrationTestCase {
// TODO test SqlGetIndicesAction. Skipping for now because of lack of serialization support.
private void setupTestIndex() {
assertAcked(client().admin().indices().prepareCreate("test").get());
ElasticsearchAssertions.assertAcked(client().admin().indices().prepareCreate("test").get());
client().prepareBulk()
.add(new IndexRequest("test", "doc", "1").source("data", "bar", "count", 42))
.add(new IndexRequest("test", "doc", "2").source("data", "baz", "count", 43))

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.sql;
package org.elasticsearch.xpack.sql.action;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.WriteRequest;

View File

@ -15,5 +15,6 @@
- match: { nodes.$master.plugins.4.name: x-pack-ml }
- match: { nodes.$master.plugins.5.name: x-pack-monitoring }
- match: { nodes.$master.plugins.6.name: x-pack-security }
- match: { nodes.$master.plugins.7.name: x-pack-upgrade }
- match: { nodes.$master.plugins.8.name: x-pack-watcher }
- match: { nodes.$master.plugins.7.name: x-pack-sql }
- match: { nodes.$master.plugins.8.name: x-pack-upgrade }
- match: { nodes.$master.plugins.9.name: x-pack-watcher }