Skip to content

Commit

Permalink
Version bump sadness
Browse files Browse the repository at this point in the history
  • Loading branch information
n1v0lg committed Aug 7, 2023
2 parents 5226afa + 1395273 commit 369e3af
Show file tree
Hide file tree
Showing 30 changed files with 861 additions and 239 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/97992.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97401
summary: Fix transform incorrectly calculating date bucket on updating old data
area: Transform
type: bug
issues:
- 97101
23 changes: 20 additions & 3 deletions docs/reference/query-rules/apis/list-query-rulesets.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,33 @@ A sample response:
"results": [
{
"ruleset_id": "ruleset-1",
"rules_count": 10
"rule_total_count": 10,
"rule_criteria_types_counts: {
"exact": 5,
"fuzzy": 5
}
},
{
"ruleset_id": "ruleset-2",
"rules_count": 15
"rule_total_count": 15,
"rule_criteria_types_counts: {
"exact": 5,
"fuzzy": 10,
"gt": 4
}
},
{
"ruleset_id": "ruleset-3",
"rules_count": 5
"rule_total_count": 5,
"rule_criteria_types_counts: {
"exact": 1,
"contains": 4
}
}
]
}
----
// TEST[skip:TBD]

[NOTE]
The counts in `rule_criteria_types_counts` may be larger than the value of `rule_total_count`, because a rule may have multiple criteria.
6 changes: 6 additions & 0 deletions docs/reference/rest-api/usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ GET /_xpack/usage
},
"analytics_collections": {
"count": 0
},
"query_rulesets": {
"total_rule_count": 0,
"total_count": 0,
"min_rule_count": 0,
"max_rule_count": 0
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId
public static final TransportVersion V_8_500_049 = registerTransportVersion(8_500_049, "828bb6ce-2fbb-11ee-be56-0242ac120002");
public static final TransportVersion V_8_500_050 = registerTransportVersion(8_500_050, "69722fa2-7c0a-4227-86fb-6d6a9a0a0321");
public static final TransportVersion V_8_500_051 = registerTransportVersion(8_500_051, "a28b43bc-bb5f-4406-afcf-26900aa98a71");
public static final TransportVersion V_8_500_052 = registerTransportVersion(8_500_052, "b76ef950-af03-4dda-85c2-6400ec442e7e");
public static final TransportVersion V_8_500_052 = registerTransportVersion(8_500_052, "2d382b3d-9838-4cce-84c8-4142113e5c2b");
public static final TransportVersion V_8_500_053 = registerTransportVersion(8_500_053, "b76ef950-af03-4dda-85c2-6400ec442e7e");

private static class CurrentHolder {
private static final TransportVersion CURRENT = findCurrent(V_8_500_052);
private static final TransportVersion CURRENT = findCurrent(V_8_500_053);

// finds the pluggable current version, or uses the given fallback
private static TransportVersion findCurrent(TransportVersion fallback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ retrieve roles dynamically. When you use the APIs to manage roles in the

The following requests use the
<<security-api-put-role,create or update roles API>>. You must have at least the
`manage_security` cluster privilege to use this API.
`manage_security` cluster privilege to use this API.

[[remote-clusters-privileges-ccr]]
//tag::configure-ccr-privileges[]
Expand All @@ -33,8 +33,11 @@ On the remote cluster that contains the leader index, the {ccr} role requires
the `read_ccr` cluster privilege, and `monitor` and `read` privileges on the
leader index.

NOTE: If requests will be issued <<run-as-privilege,on behalf of other users>>,
then the authenticating user must have the `run_as` privilege on the remote
NOTE: If requests are authenticated with an <<security-api-create-api-key, API key>>, the API key
requires the above privileges on the **local** cluster, instead of the remote.

NOTE: If requests are issued <<run-as-privilege,on behalf of other users>>,
then the authenticating user must have the `run_as` privilege on the remote
cluster.

The following request creates a `remote-replication` role on the remote cluster:
Expand Down Expand Up @@ -99,7 +102,7 @@ POST /_security/role/remote-replication
}
----

After creating the `remote-replication` role on each cluster, use the
After creating the `remote-replication` role on each cluster, use the
<<security-api-put-user,create or update users API>> to create a user on
the local cluster cluster and assign the `remote-replication` role. For
example, the following request assigns the `remote-replication` role to a user
Expand Down Expand Up @@ -133,8 +136,11 @@ local and remote clusters, and then create a user with the required roles.
On the remote cluster, the {ccs} role requires the `read` and
`read_cross_cluster` privileges for the target indices.

NOTE: If requests will be issued <<run-as-privilege,on behalf of other users>>,
then the authenticating user must have the `run_as` privilege on the remote
NOTE: If requests are authenticated with an <<security-api-create-api-key, API key>>, the API key
requires the above privileges on the **local** cluster, instead of the remote.

NOTE: If requests are issued <<run-as-privilege,on behalf of other users>>,
then the authenticating user must have the `run_as` privilege on the remote
cluster.

The following request creates a `remote-search` role on the remote cluster:
Expand Down Expand Up @@ -180,7 +186,7 @@ POST /_security/role/remote-search
{}
----

After creating the `remote-search` role on each cluster, use the
After creating the `remote-search` role on each cluster, use the
<<security-api-put-user,create or update users API>> to create a user on the
local cluster and assign the `remote-search` role. For example, the following
request assigns the `remote-search` role to a user named `cross-search-user`:
Expand Down Expand Up @@ -263,7 +269,7 @@ Assign your {kib} users a role that grants
PUT /_security/user/cross-cluster-kibana
{
"password" : "l0ng-r4nd0m-p@ssw0rd",
"roles" : [
"roles" : [
"logstash-reader",
"kibana-access"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,67 @@
import org.elasticsearch.xpack.core.XPackField;

import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class EnterpriseSearchFeatureSetUsage extends XPackFeatureSet.Usage {

static final TransportVersion BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION = TransportVersion.V_8_8_1;
static final TransportVersion QUERY_RULES_TRANSPORT_VERSION = TransportVersion.V_8_500_046;

public static final String SEARCH_APPLICATIONS = "search_applications";
public static final String ANALYTICS_COLLECTIONS = "analytics_collections";
public static final String QUERY_RULESETS = "query_rulesets";
public static final String COUNT = "count";
public static final String TOTAL_COUNT = "total_count";
public static final String TOTAL_RULE_COUNT = "total_rule_count";
public static final String MIN_RULE_COUNT = "min_rule_count";
public static final String MAX_RULE_COUNT = "max_rule_count";
public static final String RULE_CRITERIA_TOTAL_COUNTS = "rule_criteria_total_counts";

private final Map<String, Object> searchApplicationsUsage;
private final Map<String, Object> analyticsCollectionsUsage;
private final Map<String, Object> queryRulesUsage;

public EnterpriseSearchFeatureSetUsage(
boolean available,
boolean enabled,
Map<String, Object> searchApplicationsUsage,
Map<String, Object> analyticsCollectionsUsage
Map<String, Object> analyticsCollectionsUsage,
Map<String, Object> queryRulesUsage
) {
super(XPackField.ENTERPRISE_SEARCH, available, enabled);
this.searchApplicationsUsage = Objects.requireNonNull(searchApplicationsUsage);
this.analyticsCollectionsUsage = Objects.requireNonNull(analyticsCollectionsUsage);
this.queryRulesUsage = Objects.requireNonNull(queryRulesUsage);
}

public EnterpriseSearchFeatureSetUsage(StreamInput in) throws IOException {
super(in);
this.searchApplicationsUsage = in.readMap();
if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_8_1)) {
this.analyticsCollectionsUsage = in.readMap();
} else {
this.analyticsCollectionsUsage = Collections.emptyMap();
Map<String, Object> analyticsCollectionsUsage = new HashMap<>();
Map<String, Object> queryRulesUsage = new HashMap<>();
if (in.getTransportVersion().onOrAfter(QUERY_RULES_TRANSPORT_VERSION)) {
analyticsCollectionsUsage = in.readMap();
queryRulesUsage = in.readMap();
} else if (in.getTransportVersion().onOrAfter(BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION)) {
analyticsCollectionsUsage = in.readMap();
}
this.analyticsCollectionsUsage = analyticsCollectionsUsage;
this.queryRulesUsage = queryRulesUsage;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeGenericMap(searchApplicationsUsage);
if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_8_1)) {
if (out.getTransportVersion().onOrAfter(BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION)) {
out.writeGenericMap(analyticsCollectionsUsage);
}
if (out.getTransportVersion().onOrAfter(QUERY_RULES_TRANSPORT_VERSION)) {
out.writeGenericMap(queryRulesUsage);
}
}

@Override
Expand All @@ -67,6 +88,7 @@ protected void innerXContent(XContentBuilder builder, Params params) throws IOEx
super.innerXContent(builder, params);
builder.field(SEARCH_APPLICATIONS, searchApplicationsUsage);
builder.field(ANALYTICS_COLLECTIONS, analyticsCollectionsUsage);
builder.field(QUERY_RULESETS, queryRulesUsage);
}

@Override
Expand All @@ -75,12 +97,13 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
EnterpriseSearchFeatureSetUsage that = (EnterpriseSearchFeatureSetUsage) o;
return Objects.equals(searchApplicationsUsage, that.searchApplicationsUsage)
&& Objects.equals(analyticsCollectionsUsage, that.analyticsCollectionsUsage);
&& Objects.equals(analyticsCollectionsUsage, that.analyticsCollectionsUsage)
&& Objects.equals(queryRulesUsage, that.queryRulesUsage);
}

@Override
public int hashCode() {
return Objects.hash(searchApplicationsUsage, analyticsCollectionsUsage);
return Objects.hash(searchApplicationsUsage, analyticsCollectionsUsage, queryRulesUsage);
}

public Map<String, Object> getSearchApplicationsUsage() {
Expand All @@ -90,4 +113,8 @@ public Map<String, Object> getSearchApplicationsUsage() {
public Map<String, Object> getAnalyticsCollectionsUsage() {
return analyticsCollectionsUsage;
}

public Map<String, Object> getQueryRulesUsage() {
return queryRulesUsage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.core.application;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.xpack.core.ml.AbstractBWCWireSerializationTestCase;

import java.io.IOException;
import java.util.Map;

import static org.elasticsearch.xpack.core.application.EnterpriseSearchFeatureSetUsage.BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION;
import static org.elasticsearch.xpack.core.application.EnterpriseSearchFeatureSetUsage.QUERY_RULES_TRANSPORT_VERSION;

public class EnterpriseSearchFeatureSetUsageBWCSerializingTests extends AbstractBWCWireSerializationTestCase<
EnterpriseSearchFeatureSetUsage> {

@Override
protected EnterpriseSearchFeatureSetUsage createTestInstance() {
Map<String, Object> searchApplicationsStats = Map.of(EnterpriseSearchFeatureSetUsage.COUNT, randomLongBetween(0, 100000));
Map<String, Object> analyticsCollectionsStats = Map.of(EnterpriseSearchFeatureSetUsage.COUNT, randomLongBetween(0, 100000));
Map<String, Object> queryRulesStats = Map.of(EnterpriseSearchFeatureSetUsage.COUNT, randomLongBetween(0, 100000));
return new EnterpriseSearchFeatureSetUsage(true, true, searchApplicationsStats, analyticsCollectionsStats, queryRulesStats);
}

@Override
protected EnterpriseSearchFeatureSetUsage mutateInstance(EnterpriseSearchFeatureSetUsage instance) throws IOException {
return randomValueOtherThan(instance, this::createTestInstance);
}

@Override
protected Writeable.Reader<EnterpriseSearchFeatureSetUsage> instanceReader() {
return EnterpriseSearchFeatureSetUsage::new;
}

@Override
protected EnterpriseSearchFeatureSetUsage mutateInstanceForVersion(EnterpriseSearchFeatureSetUsage instance, TransportVersion version) {
if (version.onOrAfter(QUERY_RULES_TRANSPORT_VERSION)) {
return instance;
} else if (version.onOrAfter(BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION)) {
return new EnterpriseSearchFeatureSetUsage(
true,
true,
instance.getSearchApplicationsUsage(),
instance.getAnalyticsCollectionsUsage(),
Map.of()
);
} else {
return new EnterpriseSearchFeatureSetUsage(true, true, instance.getSearchApplicationsUsage(), Map.of(), Map.of());
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void testSerialization() throws IOException {
.build();
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer);
TransportVersion beforeActiveOnly = TransportVersion.V_8_500_051;
TransportVersion beforeActiveOnly = TransportVersion.V_8_500_052;
out.setTransportVersion(randomVersionBetween(random(), TransportVersion.V_8_5_0, beforeActiveOnly));
getApiKeyRequest.writeTo(out);

Expand All @@ -193,13 +193,12 @@ public void testSerialization() throws IOException {
.build();
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer);
out.setTransportVersion(randomVersionBetween(random(), TransportVersion.V_8_500_052, TransportVersion.current()));
TransportVersion activeOnlyVersion = TransportVersion.V_8_500_053;
out.setTransportVersion(randomVersionBetween(random(), activeOnlyVersion, TransportVersion.current()));
getApiKeyRequest.writeTo(out);

InputStreamStreamInput inputStreamStreamInput = new InputStreamStreamInput(new ByteArrayInputStream(outBuffer.toByteArray()));
inputStreamStreamInput.setTransportVersion(
randomVersionBetween(random(), TransportVersion.V_8_500_052, TransportVersion.current())
);
inputStreamStreamInput.setTransportVersion(randomVersionBetween(random(), activeOnlyVersion, TransportVersion.current()));
GetApiKeyRequest requestFromInputStream = new GetApiKeyRequest(inputStreamStreamInput);

assertThat(requestFromInputStream, equalTo(getApiKeyRequest));
Expand Down
Loading

0 comments on commit 369e3af

Please sign in to comment.