diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-22 14:34:57 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-22 14:34:57 +0100 |
commit | 1d5806f068309e18b70fee03b7a22e111c180607 (patch) | |
tree | 83eddc958301445e5d9b13ea602f963a39a7f5e2 /config-model/src/test/java/com/yahoo | |
parent | 1f2865c97efe67f6f54151c26990226063c85d26 (diff) |
Improve error messages
Diffstat (limited to 'config-model/src/test/java/com/yahoo')
3 files changed, 46 insertions, 8 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java index 452a9fcdf87..6f8547c3701 100644 --- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java @@ -684,6 +684,37 @@ public class ModelProvisioningTest { } @Test + public void testIllegalGroupSize() { + String services = + "<?xml version='1.0' encoding='utf-8' ?>\n" + + "<services>" + + " <admin version='4.0'/>" + + " <container version='1.0' id='foo'>" + + " <nodes count='2'/>" + + " </container>" + + " <content version='1.0' id='bar'>" + + " <redundancy>2</redundancy>" + + " <documents>" + + " <document type='type1' mode='index'/>" + + " </documents>" + + " <nodes count='5' group-size='[2, --]'/>" + + " </content>" + + "</services>"; + + int numberOfHosts = 10; + VespaModelTester tester = new VespaModelTester(); + tester.addHosts(numberOfHosts); + try { + tester.createModel(services, true); + fail("Expected exception"); + } + catch (IllegalArgumentException e) { + assertEquals("In content cluster 'bar': Illegal group-size value: " + + "Expected a number or range on the form [min, max], but got '[2, --]': '--' is not an integer", Exceptions.toMessageString(e)); + } + } + + @Test public void testSlobroksOnContainersIfNoContentClusters() { String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + @@ -1193,7 +1224,8 @@ public class ModelProvisioningTest { fail("Expected exception"); } catch (IllegalArgumentException e) { - assertEquals("Cluster 'bar' specifies redundancy 2, but it cannot be higher than the minimum nodes per group, which is 1", Exceptions.toMessageString(e)); + assertEquals("In content cluster 'bar': This cluster specifies redundancy 2, " + + "but this cannot be higher than the minimum nodes per group, which is 1", Exceptions.toMessageString(e)); } } @@ -1789,7 +1821,9 @@ public class ModelProvisioningTest { VespaModel model = tester.createModel(new Zone(Environment.staging, RegionName.from("us-central-1")), services, true); fail("expected failure"); } catch (IllegalArgumentException e) { - assertTrue(e.getMessage().startsWith("Clusters in hosted environments must have a <nodes count='N'> tag")); + assertEquals("In content cluster 'bar': Clusters in hosted environments must have a <nodes count='N'> tag\n" + + "matching all zones, and having no <node> subtags,\nsee https://cloud.vespa.ai/en/reference/services", + Exceptions.toMessageString(e)); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java index 07c032a52a5..7fba5ba12e9 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java @@ -6,6 +6,7 @@ import com.yahoo.vespa.model.content.cluster.ContentCluster; import com.yahoo.vespa.model.search.DispatchGroup; import com.yahoo.vespa.model.search.SearchInterface; import com.yahoo.vespa.model.search.SearchNode; +import com.yahoo.yolean.Exceptions; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -176,7 +177,8 @@ public class IndexedHierarchicDistributionTest { getIllegalMultipleGroupsLevelCluster(); fail("Did not get expected Exception"); } catch (Exception e) { - assertTrue(e.getMessage().contains("sub group 'group0' contains 2 sub groups.")); + assertEquals("Expected all groups under root group 'null' to be leaf groups only containing nodes, but sub group 'group0' contains 2 sub groups", + Exceptions.toMessageString(e)); } } @@ -220,7 +222,8 @@ public class IndexedHierarchicDistributionTest { getTwoGroupsCluster(3, 3, "2|*"); fail("Did not get expected Exception"); } catch (Exception e) { - assertTrue(e.getMessage().contains("Expected number of leaf groups (2) to be a factor of redundancy (3)")); + assertEquals("In content cluster 'mycluster': Expected number of leaf groups (2) to be a factor of redundancy (3), but it is not", + Exceptions.toMessageString(e)); } } @@ -240,7 +243,7 @@ public class IndexedHierarchicDistributionTest { getTwoGroupsCluster(4, 3, "2|*"); fail("Did not get expected Exception"); } catch (Exception e) { - assertTrue(e.getMessage().contains("Expected equal amount of ready copies per group")); + assertEquals("In content cluster 'mycluster': Expected equal amount of ready copies per group, but 3 ready copies is specified with 2 groups", Exceptions.toMessageString(e)); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java index 9fb4eefba75..57ee15a1dc4 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/StorageClusterTest.java @@ -21,6 +21,7 @@ import static com.yahoo.config.model.test.TestUtil.joinLines; import com.yahoo.vespa.model.content.cluster.ContentCluster; import com.yahoo.vespa.model.content.storagecluster.StorageCluster; import com.yahoo.vespa.model.content.utils.ContentClusterUtils; +import com.yahoo.yolean.Exceptions; import org.junit.jupiter.api.Test; @@ -432,8 +433,8 @@ public class StorageClusterTest { ContentClusterUtils.createCluster(xml, root); fail("Did not fail when having both group and nodes"); } catch (RuntimeException e) { - assertEquals("Both <group> and <nodes> is specified: Only one of these tags can be used in the same configuration", - e.getMessage()); + assertEquals("In content cluster 'storage': Both <group> and <nodes> is specified: Only one of these tags can be used in the same configuration", + Exceptions.toMessageString(e)); } } @@ -507,7 +508,7 @@ public class StorageClusterTest { ContentClusterUtils.createCluster(xml, new MockRoot()); fail("Did not get exception with missing distribution element"); } catch (RuntimeException e) { - assertEquals("'distribution' attribute is required with multiple subgroups", e.getMessage()); + assertEquals("In content cluster 'storage': 'distribution' attribute is required with multiple subgroups", Exceptions.toMessageString(e)); } } } |