Merge remote-tracking branch 'origin/feature_naming_group' into feature_naming_group

This commit is contained in:
nkorange 2019-03-08 17:18:13 +08:00
commit b75ea9f333

View File

@ -16,6 +16,7 @@
package com.alibaba.nacos.test.naming; package com.alibaba.nacos.test.naming;
import java.net.URL; import java.net.URL;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -28,6 +29,7 @@ import com.alibaba.nacos.api.naming.CommonParams;
import com.alibaba.nacos.api.naming.NamingFactory; import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance; import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.naming.NamingApp; import com.alibaba.nacos.naming.NamingApp;
import org.junit.After; import org.junit.After;
@ -192,7 +194,7 @@ public class CPInstancesAPI_ITCase {
} }
/** /**
* @TCDescription : 根据serviceName修改服务获取服务信息 * @TCDescription : 根据serviceName修改服务通过HTTP接口获取服务信息
* @TestStep : * @TestStep :
* @ExpectResult : * @ExpectResult :
*/ */
@ -205,7 +207,7 @@ public class CPInstancesAPI_ITCase {
Params.newParams() Params.newParams()
.appendParam("serviceName", serviceName) .appendParam("serviceName", serviceName)
.appendParam("namespaceId", TEST_NAMESPACE_1) .appendParam("namespaceId", TEST_NAMESPACE_1)
.appendParam("protectThreshold", "9.0") .appendParam("protectThreshold", "0.5")
.done(), .done(),
String.class, String.class,
HttpMethod.PUT); HttpMethod.PUT);
@ -224,7 +226,26 @@ public class CPInstancesAPI_ITCase {
JSONObject json = JSON.parseObject(response.getBody()); JSONObject json = JSON.parseObject(response.getBody());
Assert.assertEquals(serviceName, json.getString("name")); Assert.assertEquals(serviceName, json.getString("name"));
Assert.assertEquals("9.0", json.getString("protectThreshold")); Assert.assertEquals("0.5", json.getString("protectThreshold"));
namingServiceDelete(serviceName, TEST_NAMESPACE_1);
}
/**
* @TCDescription : 根据serviceName修改服务并通过接口获取服务信息
* @TestStep :
* @ExpectResult :
*/
@Test
public void getService_1() throws Exception {
String serviceName = NamingBase.randomDomainName();
ListView<String> listView = naming1.getServicesOfServer(1, 20);
namingServiceCreate(serviceName, TEST_NAMESPACE_1);
TimeUnit.SECONDS.sleep(5L);
ListView<String> listView1 = naming1.getServicesOfServer(1, 20);
Assert.assertEquals(listView.getCount()+1, listView1.getCount());
namingServiceDelete(serviceName, TEST_NAMESPACE_1); namingServiceDelete(serviceName, TEST_NAMESPACE_1);
} }
@ -284,6 +305,31 @@ public class CPInstancesAPI_ITCase {
namingServiceDelete(serviceName, Constants.DEFAULT_NAMESPACE_ID); namingServiceDelete(serviceName, Constants.DEFAULT_NAMESPACE_ID);
} }
/**
* @TCDescription : 根据serviceName创建服务注册持久化实例, 查询实例注销实例删除服务
* @TestStep :
* @ExpectResult :
*/
@Test
public void registerInstance_query() throws Exception {
String serviceName = NamingBase.randomDomainName();
namingServiceCreate(serviceName, Constants.DEFAULT_NAMESPACE_ID);
instanceRegister(serviceName, Constants.DEFAULT_NAMESPACE_ID, "33.33.33.33", TEST_PORT2_4_DOM_1);
List<Instance> instances = naming.getAllInstances(serviceName);
Assert.assertEquals(1, instances.size());
Assert.assertEquals("33.33.33.33", instances.get(0).getIp());
instanceDeregister(serviceName, Constants.DEFAULT_NAMESPACE_ID, "33.33.33.33", TEST_PORT2_4_DOM_1);
TimeUnit.SECONDS.sleep(3L);
instances = naming.getAllInstances(serviceName);
Assert.assertEquals(0, instances.size());
namingServiceDelete(serviceName, Constants.DEFAULT_NAMESPACE_ID);
}
/** /**
* @TCDescription : 根据serviceName创建服务注册不同group的2个持久化实例, 注销实例删除服务 * @TCDescription : 根据serviceName创建服务注册不同group的2个持久化实例, 注销实例删除服务
* @TestStep : * @TestStep :