mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'feature/SEARCH-574_REST_API_for_Shard_status_info' into 'master'
SEARCH-574 (Add publc admin API to expose index shard status) See merge request tas/alfresco-tas-restapi-test!52
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2018 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.rest.search;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Shard info end point REST API test.
|
||||
*
|
||||
* @author Tuna Aksoy
|
||||
*/
|
||||
public class ShardInfoTest extends AbstractSearchTest
|
||||
{
|
||||
@Bug(id="DELENG-1", status=Bug.Status.OPENED)
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API})
|
||||
public void getShardInfoWithAdminAuthority() throws JsonProcessingException, EmptyRestModelCollectionException
|
||||
{
|
||||
RestShardInfoModelCollection info = restClient.authenticateUser(dataUser.getAdminUser()).withShardInfoAPI().getInfo();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
info.assertThat().entriesListIsNotEmpty();
|
||||
assertEquals(info.getPagination().getTotalItems().intValue(), 2);
|
||||
|
||||
List<String> stores = Arrays.asList("workspace://SpacesStore", "archive://SpacesStore");
|
||||
List<String> baseUrls = Arrays.asList("/solr/alfresco", "/solr/archive");
|
||||
|
||||
List<RestShardInfoModel> entries = info.getEntries();
|
||||
for (RestShardInfoModel shardInfoModel : entries)
|
||||
{
|
||||
RestShardInfoModel model = shardInfoModel.getModel();
|
||||
assertEquals(model.getTemplate(), "rerank");
|
||||
assertEquals(model.getMode(), "MASTER");
|
||||
assertEquals(model.getShardMethod(), "DB_ID");
|
||||
assertTrue(model.getHasContent());
|
||||
stores.contains(model.getStores());
|
||||
List<RestShardModel> shards = model.getShards();
|
||||
assertNotNull(shards);
|
||||
RestShardModel shard = shards.iterator().next();
|
||||
assertNotNull(shard);
|
||||
List<RestInstanceModel> instances = shard.getInstances();
|
||||
assertNotNull(instances);
|
||||
RestInstanceModel instance = instances.iterator().next();
|
||||
assertNotNull(instance);
|
||||
baseUrls.contains(instance.getBaseUrl());
|
||||
assertEquals(instance.getHost(), "localhost");
|
||||
assertEquals(instance.getPort().intValue(), 8983);
|
||||
assertEquals(instance.getState(), "ACTIVE");
|
||||
assertEquals(instance.getMode(), "MASTER");
|
||||
}
|
||||
}
|
||||
|
||||
@Bug(id="DELENG-1", status=Bug.Status.OPENED)
|
||||
@Test(groups={TestGroup.SEARCH, TestGroup.REST_API})
|
||||
public void getShardInfoWithoutAdminAuthority() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser()).withShardInfoAPI().getInfo();
|
||||
restClient.assertStatusCodeIs(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user