Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Bozhko committed May 21, 2024
1 parent a10a3e9 commit 53ba0bf
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,8 @@ public void testProperties() throws Exception {
public void testModifyPropertiesV2() throws Exception {
final String aliasName = getSaferTestName();
ZkStateReader zkStateReader = createColectionsAndAlias(aliasName);
final String baseUrl =
cluster.getRandomJetty(random()).getBaseUrl().toString().replace("/solr", "");
String aliasApi = String.format(Locale.ENGLISH, "/api/aliases/%s/properties", aliasName);
final String baseUrl = cluster.getRandomJetty(random()).getBaseURLV2().toString();
String aliasApi = String.format(Locale.ENGLISH, "/aliases/%s/properties", aliasName);

HttpPut withoutBody = new HttpPut(baseUrl + aliasApi);
assertEquals(400, httpClient.execute(withoutBody).getStatusLine().getStatusCode());
Expand All @@ -260,7 +259,7 @@ public void testModifyPropertiesV2() throws Exception {
checkFooAndBarMeta(aliasName, zkStateReader, "baz", "bam");

String aliasPropertyApi =
String.format(Locale.ENGLISH, "/api/aliases/%s/properties/%s", aliasName, "foo");
String.format(Locale.ENGLISH, "/aliases/%s/properties/%s", aliasName, "foo");
HttpPut updateByProperty = new HttpPut(baseUrl + aliasPropertyApi);
updateByProperty.setEntity(
new StringEntity("{ \"value\": \"zab\" }", ContentType.APPLICATION_JSON));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ public void testFailOnSingleNode() throws Exception {
Map<?, ?> r = null;

String uri =
cluster.getJettySolrRunners().get(0).getBaseUrl().toString().replace("/solr", "")
+ "/api/cluster/replicas/migrate";
cluster.getJettySolrRunners().get(0).getBaseURLV2().toString()
+ "/cluster/replicas/migrate";
try {
httpRequest = new HttpPost(uri);

Expand Down
10 changes: 4 additions & 6 deletions solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ private long uploadGivenConfigSet(
final ByteBuffer fileBytes =
TestSolrConfigHandler.getFileContent(file.getAbsolutePath(), false);
final String uriEnding =
"/api/cluster/configs/"
"/cluster/configs/"
+ configSetName
+ suffix
+ (!overwrite ? "?overwrite=false" : "")
Expand All @@ -1590,8 +1590,7 @@ private long uploadGivenConfigSet(
Map<?, ?> map =
postDataAndGetResponse(
cluster.getSolrClient(),
cluster.getJettySolrRunners().get(0).getBaseUrl().toString().replace("/solr", "")
+ uriEnding,
cluster.getJettySolrRunners().get(0).getBaseURLV2().toString() + uriEnding,
fileBytes,
username,
usePut);
Expand Down Expand Up @@ -1634,7 +1633,7 @@ private long uploadSingleConfigSetFile(
final ByteBuffer sampleConfigFile =
TestSolrConfigHandler.getFileContent(file.getAbsolutePath(), false);
final String uriEnding =
"/api/cluster/configs/"
"/cluster/configs/"
+ configSetName
+ suffix
+ "/"
Expand All @@ -1646,8 +1645,7 @@ private long uploadSingleConfigSetFile(
Map<?, ?> map =
postDataAndGetResponse(
cluster.getSolrClient(),
cluster.getJettySolrRunners().get(0).getBaseUrl().toString().replace("/solr", "")
+ uriEnding,
cluster.getJettySolrRunners().get(0).getBaseURLV2().toString() + uriEnding,
sampleConfigFile,
username,
usePut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void testFileStoreManagement() throws Exception {
return true;
});
for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
String baseUrl = jettySolrRunner.getBaseUrl().toString().replace("/solr", "/api");
String baseUrl = jettySolrRunner.getBaseURLV2().toString();
String url = baseUrl + "/node/files/package/mypkg/v1.0?wt=javabin";
assertResponseValues(10, new Fetcher(url, jettySolrRunner), expected);
}
Expand All @@ -196,7 +196,7 @@ public static void checkAllNodesForFile(
boolean verifyContent)
throws Exception {
for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
String baseUrl = jettySolrRunner.getBaseUrl().toString().replace("/solr", "/api");
String baseUrl = jettySolrRunner.getBaseURLV2().toString();
String url = baseUrl + "/node/files" + path + "?wt=javabin&meta=true";
assertResponseValues(10, new Fetcher(url, jettySolrRunner), expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ private V2Request postPlugin(Object payload) {

public void waitForAllNodesToSync(String path, Map<String, Object> expected) throws Exception {
for (JettySolrRunner jettySolrRunner : cluster.getJettySolrRunners()) {
String baseUrl = jettySolrRunner.getBaseUrl().toString().replace("/solr", "/api");
String baseUrl = jettySolrRunner.getBaseURLV2().toString();
String url = baseUrl + path + "?wt=javabin";
TestDistribFileStore.assertResponseValues(1, new Fetcher(url, jettySolrRunner), expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ public void setUp() throws Exception {
super.setUp();

baseUrl = cluster.getJettySolrRunner(0).getBaseUrl();
basezk = baseUrl.toString().replace("/solr", "/api") + "/cluster/zookeeper/data";
basezkls = baseUrl.toString().replace("/solr", "/api") + "/cluster/zookeeper/children";

String baseUrlV2 = cluster.getJettySolrRunner(0).getBaseURLV2().toString();
basezk = baseUrlV2 + "/cluster/zookeeper/data";
basezkls = baseUrlV2 + "/cluster/zookeeper/children";
}

@After
Expand Down
3 changes: 1 addition & 2 deletions solr/core/src/test/org/apache/solr/pkg/TestPackages.java
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ public void testAPI() throws Exception {
// So far we have been verifying the details with ZK directly
// use the package read API to verify with each node that it has the correct data
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
String path =
jetty.getBaseUrl().toString().replace("/solr", "/api") + "/cluster/package?wt=javabin";
String path = jetty.getBaseURLV2().toString() + "/cluster/package?wt=javabin";
TestDistribFileStore.assertResponseValues(
10,
new Callable<NavigableObject>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,11 @@ public void searchWithException() throws Exception {
@Test
public void illegalAdminPathError() throws Exception {
setupCluster(false, null, false);
String baseUrl = testHarness.get().cluster.getJettySolrRunner(0).getBaseUrl().toString();
String baseUrl = testHarness.get().cluster.getJettySolrRunner(0).getBaseURLV2().toString();
expectThrows(
FileNotFoundException.class,
() -> {
try (InputStream is =
new URL(baseUrl.replace("/solr", "") + "/api/node/foo").openStream()) {
try (InputStream is = new URL(baseUrl + "/node/foo").openStream()) {
new String(is.readAllBytes(), StandardCharsets.UTF_8);
}
});
Expand Down

0 comments on commit 53ba0bf

Please sign in to comment.