|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | + |
| 9 | +import org.elasticsearch.gradle.VersionProperties |
| 10 | +import org.elasticsearch.gradle.internal.info.BuildParams |
| 11 | +import org.elasticsearch.gradle.internal.test.rest.CopyRestTestsTask |
| 12 | +import org.elasticsearch.gradle.util.GradleUtils |
| 13 | + |
| 14 | +apply plugin: 'elasticsearch.yaml-rest-compat-test' |
| 15 | + |
| 16 | +/** |
| 17 | + * This project exists to test the _xpack prefix for REST compatibility. The _xpack prefix was removed from the specification, but still supported |
| 18 | + * in 7x. This project re-introduces the _xpack prefix in the specification but only for compatibility testing purposes. |
| 19 | + */ |
| 20 | + |
| 21 | +configurations { |
| 22 | + compatXpackTests |
| 23 | +} |
| 24 | + |
| 25 | +int compatVersion = VersionProperties.getElasticsearchVersion().getMajor() - 1; |
| 26 | + |
| 27 | +dependencies { |
| 28 | + "yamlRestTestV${compatVersion}CompatImplementation" project(':test:framework') |
| 29 | + "yamlRestTestV${compatVersion}CompatImplementation"(testArtifact(xpackProject('plugin'))) |
| 30 | + compatXpackTests project(path: ':x-pack:plugin', configuration: 'restCompatTests') |
| 31 | +} |
| 32 | + |
| 33 | +// copy the already transformed compatible rest tests from the x-pack compatible tests |
| 34 | +tasks.named("copyRestCompatTestTask").configure { task -> |
| 35 | + task.dependsOn(configurations.compatXpackTests); |
| 36 | + task.setXpackConfig(configurations.compatXpackTests); |
| 37 | + task.getIncludeXpack().set(List.of("ml", "rollup", "license", "migration", "ssl")); |
| 38 | + task.getOutputResourceDir().set(project.getLayout().getBuildDirectory().dir("restResources/v${compatVersion}/yamlTests/original")); |
| 39 | + task.setXpackConfigToFileTree( |
| 40 | + config -> project.fileTree( |
| 41 | + config.getSingleFile().toPath() |
| 42 | + ) |
| 43 | + ) |
| 44 | + } |
| 45 | + |
| 46 | +// location for keys and certificates |
| 47 | +File extraResourceDir = file("$buildDir/extra_resource") |
| 48 | +File nodeKey = file("$extraResourceDir/testnode.pem") |
| 49 | +File nodeCert = file("$extraResourceDir/testnode.crt") |
| 50 | +// location for service tokens |
| 51 | +File serviceTokens = file("$extraResourceDir/service_tokens") |
| 52 | + |
| 53 | +// Add key and certs to test classpath: it expects them there |
| 54 | +// User cert and key PEM files instead of a JKS Keystore for the cluster's trust material so that |
| 55 | +// it can run in a FIPS 140 JVM |
| 56 | +// TODO: Remove all existing uses of cross project file references when the new approach for referencing static files is available |
| 57 | +// https://github.com/elastic/elasticsearch/pull/32201 |
| 58 | +tasks.register("copyExtraResources", Copy) { |
| 59 | + from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) { |
| 60 | + include 'testnode.crt', 'testnode.pem' |
| 61 | + } |
| 62 | + from(project(':x-pack:plugin:security:qa:service-account').file('src/javaRestTest/resources/')) { |
| 63 | + include 'service_tokens' |
| 64 | + } |
| 65 | + into extraResourceDir |
| 66 | +} |
| 67 | +// Add keystores to test classpath: it expects it there |
| 68 | +sourceSets."yamlRestTestV${compatVersion}Compat".resources.srcDir(extraResourceDir) |
| 69 | +tasks.named("processYamlRestTestV${compatVersion}CompatResources").configure { |
| 70 | + dependsOn("copyExtraResources") |
| 71 | +} |
| 72 | + |
| 73 | +testClusters.configureEach { |
| 74 | + testDistribution = 'DEFAULT' // this is important since we use the reindex module in ML |
| 75 | + setting 'xpack.ml.enabled', 'true' |
| 76 | + setting 'xpack.security.enabled', 'true' |
| 77 | + setting 'xpack.watcher.enabled', 'false' |
| 78 | + setting 'xpack.security.authc.token.enabled', 'true' |
| 79 | + setting 'xpack.security.authc.api_key.enabled', 'true' |
| 80 | + setting 'xpack.security.transport.ssl.enabled', 'true' |
| 81 | + setting 'xpack.security.transport.ssl.key', nodeKey.name |
| 82 | + setting 'xpack.security.transport.ssl.certificate', nodeCert.name |
| 83 | + setting 'xpack.security.transport.ssl.verification_mode', 'certificate' |
| 84 | + setting 'xpack.security.audit.enabled', 'true' |
| 85 | + setting 'xpack.license.self_generated.type', 'trial' |
| 86 | + // disable ILM history, since it disturbs tests using _all |
| 87 | + setting 'indices.lifecycle.history_index_enabled', 'false' |
| 88 | + keystore 'bootstrap.password', 'x-pack-test-password' |
| 89 | + keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode' |
| 90 | + setting 'xpack.searchable.snapshot.shared_cache.size', '10mb' |
| 91 | + |
| 92 | + user username: "x_pack_rest_user", password: "x-pack-test-password" |
| 93 | + extraConfigFile nodeKey.name, nodeKey |
| 94 | + extraConfigFile nodeCert.name, nodeCert |
| 95 | + extraConfigFile serviceTokens.name, serviceTokens |
| 96 | + |
| 97 | + if (BuildParams.isSnapshotBuild() == false) { |
| 98 | + systemProperty 'es.index_mode_feature_flag_registered', 'true' |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +// transform (again) the (already) transformed x-pack compatibility tests to test the xpack prefixes |
| 103 | +tasks.named("yamlRestTestV7CompatTransform").configure{ task -> |
| 104 | + |
| 105 | + task.replaceKeyInDo("license.delete", "xpack-license.delete") |
| 106 | + task.replaceKeyInDo("license.get", "xpack-license.get") |
| 107 | + task.replaceKeyInDo("license.get_basic_status", "xpack-license.get_basic_status") |
| 108 | + task.replaceKeyInDo("license.get_trial_status", "xpack-license.get_trial_status") |
| 109 | + task.replaceKeyInDo("license.post", "xpack-license.post") |
| 110 | + task.replaceKeyInDo("license.post_start_basic", "xpack-license.post_start_basic") |
| 111 | + task.replaceKeyInDo("license.post_start_trial", "xpack-license.post_start_trial") |
| 112 | + task.addAllowedWarningRegex(".*_xpack/license.* is deprecated.*") |
| 113 | + |
| 114 | + task.replaceKeyInDo("migration.deprecations", "xpack-migration.deprecations") |
| 115 | + task.addAllowedWarningRegex(".*_xpack/migration.* is deprecated.*") |
| 116 | + |
| 117 | + task.replaceKeyInDo("rollup.delete_job", "xpack-rollup.delete_job") |
| 118 | + task.replaceKeyInDo("rollup.get_jobs", "xpack-rollup.get_jobs") |
| 119 | + task.replaceKeyInDo("rollup.get_rollup_caps", "xpack-rollup.get_rollup_caps") |
| 120 | + task.replaceKeyInDo("rollup.get_rollup_index_caps", "xpack-rollup.get_rollup_index_caps") |
| 121 | + task.replaceKeyInDo("rollup.put_job", "xpack-rollup.put_job") |
| 122 | + task.replaceKeyInDo("rollup.start_job", "xpack-rollup.start_job") |
| 123 | + task.replaceKeyInDo("rollup.stop_job", "xpack-rollup.stop_job") |
| 124 | + task.addAllowedWarningRegex(".*_xpack/rollup.* is deprecated.*") |
| 125 | + |
| 126 | + task.replaceKeyInDo("ml.close_job", "xpack-ml.close_job") |
| 127 | + task.replaceKeyInDo("ml.delete_calendar", "xpack-ml.delete_calendar") |
| 128 | + task.replaceKeyInDo("ml.delete_calendar_event", "xpack-ml.delete_calendar_event") |
| 129 | + task.replaceKeyInDo("ml.delete_calendar_job", "xpack-ml.delete_calendar_job") |
| 130 | + task.replaceKeyInDo("ml.delete_datafeed", "xpack-ml.delete_datafeed") |
| 131 | + task.replaceKeyInDo("ml.delete_expired_data", "xpack-ml.delete_expired_data") |
| 132 | + task.replaceKeyInDo("ml.delete_filter", "xpack-ml.delete_filter") |
| 133 | + task.replaceKeyInDo("ml.delete_forecast", "xpack-ml.delete_forecast") |
| 134 | + task.replaceKeyInDo("ml.delete_job", "xpack-ml.delete_job") |
| 135 | + task.replaceKeyInDo("ml.delete_model_snapshot", "xpack-ml.delete_model_snapshot") |
| 136 | + task.replaceKeyInDo("ml.flush_job", "xpack-ml.flush_job") |
| 137 | + task.replaceKeyInDo("ml.forecast", "xpack-ml.forecast") |
| 138 | + task.replaceKeyInDo("ml.get_buckets", "xpack-ml.get_buckets") |
| 139 | + task.replaceKeyInDo("ml.get_calendar_events", "xpack-ml.get_calendar_events") |
| 140 | + task.replaceKeyInDo("ml.get_calendars", "xpack-ml.get_calendars") |
| 141 | + task.replaceKeyInDo("ml.get_categories", "xpack-ml.get_categories") |
| 142 | + task.replaceKeyInDo("ml.get_datafeed_stats", "xpack-ml.get_datafeed_stats") |
| 143 | + task.replaceKeyInDo("ml.get_datafeeds", "xpack-ml.get_datafeeds") |
| 144 | + task.replaceKeyInDo("ml.get_filters", "xpack-ml.get_filters") |
| 145 | + task.replaceKeyInDo("ml.get_influencers", "xpack-ml.get_influencers") |
| 146 | + task.replaceKeyInDo("ml.get_job_stats", "xpack-ml.get_job_stats") |
| 147 | + task.replaceKeyInDo("ml.get_jobs", "xpack-ml.get_jobs") |
| 148 | + task.replaceKeyInDo("ml.get_model_snapshots", "xpack-ml.get_model_snapshots") |
| 149 | + task.replaceKeyInDo("ml.get_overall_buckets", "xpack-ml.get_overall_buckets") |
| 150 | + task.replaceKeyInDo("ml.get_records", "xpack-ml.get_records") |
| 151 | + task.replaceKeyInDo("ml.info", "xpack-ml.info") |
| 152 | + task.replaceKeyInDo("ml.open_job", "xpack-ml.open_job") |
| 153 | + task.replaceKeyInDo("ml.post_calendar_events", "xpack-ml.post_calendar_events") |
| 154 | + task.replaceKeyInDo("ml.post_data", "xpack-ml.post_data") |
| 155 | + task.replaceKeyInDo("ml.preview_datafeed", "xpack-ml.preview_datafeed") |
| 156 | + task.replaceKeyInDo("ml.put_calendar", "xpack-ml.put_calendar") |
| 157 | + task.replaceKeyInDo("ml.put_calendar_job", "xpack-ml.put_calendar_job") |
| 158 | + task.replaceKeyInDo("ml.put_datafeed", "xpack-ml.put_datafeed") |
| 159 | + task.replaceKeyInDo("ml.put_filter", "xpack-ml.put_filter") |
| 160 | + task.replaceKeyInDo("ml.put_job", "xpack-ml.put_job") |
| 161 | + task.replaceKeyInDo("ml.revert_model_snapshot", "xpack-ml.revert_model_snapshot") |
| 162 | + task.replaceKeyInDo("ml.set_upgrade_mode", "xpack-ml.set_upgrade_mode") |
| 163 | + task.replaceKeyInDo("ml.start_datafeed", "xpack-ml.start_datafeed") |
| 164 | + task.replaceKeyInDo("ml.stop_datafeed", "xpack-ml.stop_datafeed") |
| 165 | + task.replaceKeyInDo("ml.update_datafeed", "xpack-ml.update_datafeed") |
| 166 | + task.replaceKeyInDo("ml.update_filter", "xpack-ml.update_filter") |
| 167 | + task.replaceKeyInDo("ml.update_job", "xpack-ml.update_job") |
| 168 | + task.replaceKeyInDo("ml.update_model_snapshot", "xpack-ml.update_model_snapshot") |
| 169 | + task.replaceKeyInDo("ml.validate", "xpack-ml.validate") |
| 170 | + task.replaceKeyInDo("ml.validate_detector", "xpack-ml.validate_detector") |
| 171 | + task.addAllowedWarningRegex(".*_xpack/ml.* is deprecated.*") |
| 172 | + |
| 173 | + task.replaceKeyInDo("ssl.certificates", "xpack-ssl.certificates", "Test get SSL certificates") |
| 174 | + task.addAllowedWarningRegexForTest(".*_xpack/ssl.* is deprecated.*", "Test get SSL certificates") |
| 175 | +} |
0 commit comments