Skip to content

Commit fbfe58c

Browse files
committed
Update validation messages
1 parent a02c11d commit fbfe58c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/license/License.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,16 @@ private void validate() {
422422
private static void validateLimits(String type, int maxNodes, int maxResourceUnits) {
423423
if (LicenseType.isEnterprise(type)) {
424424
if (maxResourceUnits == -1) {
425-
throw new IllegalStateException("maxResourceUnits must be set for enterprise licenses");
425+
throw new IllegalStateException("maxResourceUnits must be set for enterprise licenses (type=[" + type + "])");
426426
} else if (maxNodes != -1) {
427-
throw new IllegalStateException("maxNodes may not be set for enterprise licenses");
427+
throw new IllegalStateException("maxNodes may not be set for enterprise licenses (type=[" + type + "])");
428428
}
429429
} else {
430430
if (maxNodes == -1) {
431431
throw new IllegalStateException("maxNodes has to be set");
432432
} else if (maxResourceUnits != -1) {
433-
throw new IllegalStateException("maxResourceUnits may only be set for enterprise licenses");
433+
throw new IllegalStateException("maxResourceUnits may only be set for enterprise licenses (not permitted for type=[" +
434+
type + "])");
434435
}
435436
}
436437
}

x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicenseTests.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ public void testThatEnterpriseLicenseMayNotHaveMaxNodes() throws Exception {
121121
.maxNodes(randomIntBetween(1, 50))
122122
.maxResourceUnits(randomIntBetween(10, 500));
123123
final IllegalStateException ex = expectThrows(IllegalStateException.class, builder::build);
124-
assertThat(ex, TestMatchers.throwableWithMessage("maxNodes may not be set for enterprise licenses"));
124+
assertThat(ex, TestMatchers.throwableWithMessage("maxNodes may not be set for enterprise licenses (type=[enterprise])"));
125125
}
126126

127127
public void testThatEnterpriseLicenseMustHaveMaxResourceUnits() throws Exception {
128128
License.Builder builder = randomLicense(License.LicenseType.ENTERPRISE)
129129
.maxResourceUnits(-1);
130130
final IllegalStateException ex = expectThrows(IllegalStateException.class, builder::build);
131-
assertThat(ex, TestMatchers.throwableWithMessage("maxResourceUnits must be set for enterprise licenses"));
131+
assertThat(ex, TestMatchers.throwableWithMessage("maxResourceUnits must be set for enterprise licenses (type=[enterprise])"));
132132
}
133133

134134
public void testThatRegularLicensesMustHaveMaxNodes() throws Exception {
@@ -145,7 +145,8 @@ public void testThatRegularLicensesMayNotHaveMaxResourceUnits() throws Exception
145145
.maxResourceUnits(randomIntBetween(10, 500))
146146
.maxNodes(randomIntBetween(1, 50));
147147
final IllegalStateException ex = expectThrows(IllegalStateException.class, builder::build);
148-
assertThat(ex, TestMatchers.throwableWithMessage("maxResourceUnits may only be set for enterprise licenses"));
148+
assertThat(ex, TestMatchers.throwableWithMessage("maxResourceUnits may only be set for enterprise licenses (not permitted " +
149+
"for type=[" + type.getTypeName() + "])"));
149150
}
150151

151152
public void testLicenseToAndFromXContentForEveryLicenseType() throws Exception {

0 commit comments

Comments
 (0)