From 025b1b49801c325440bf294a31a9e8bde2ae7ee2 Mon Sep 17 00:00:00 2001 From: nkorange Date: Mon, 2 Mar 2020 16:47:13 +0800 Subject: [PATCH] Fix test case error --- .../config/server/service/ServerListService.java | 8 ++++++++ config/src/main/resources/META-INF/nacos-db.sql | 2 +- config/src/main/resources/META-INF/schema.sql | 2 +- console/src/main/resources/META-INF/schema.sql | 2 +- .../alibaba/nacos/test/base/HttpClient4Test.java | 15 +++++++++++++++ .../nacos/test/core/auth/ConfigAuth_ITCase.java | 8 ++++++-- .../nacos/test/naming/CPInstancesAPI_ITCase.java | 4 ++-- test/src/test/resources/schema.sql | 2 +- 8 files changed, 35 insertions(+), 8 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/ServerListService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/ServerListService.java index f3635ce43..e8960857f 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/ServerListService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/ServerListService.java @@ -394,6 +394,14 @@ public class ServerListService implements ApplicationListener newList = new ArrayList(); + for (String serverAddrTmp : serverList) { + newList.add(getFormatServerAddr(serverAddrTmp)); + } + setServerList(new ArrayList(newList)); + } httpclient.start(); CheckServerHealthTask checkServerHealthTask = new CheckServerHealthTask(); TimerTaskService.scheduleWithFixedDelay(checkServerHealthTask, 0L, 5L, TimeUnit.SECONDS); diff --git a/config/src/main/resources/META-INF/nacos-db.sql b/config/src/main/resources/META-INF/nacos-db.sql index 0e8b29aa6..f7953e5a1 100644 --- a/config/src/main/resources/META-INF/nacos-db.sql +++ b/config/src/main/resources/META-INF/nacos-db.sql @@ -199,4 +199,4 @@ CREATE TABLE permissions ( INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); -INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN'); +INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN'); diff --git a/config/src/main/resources/META-INF/schema.sql b/config/src/main/resources/META-INF/schema.sql index 90c499746..06d0b000b 100644 --- a/config/src/main/resources/META-INF/schema.sql +++ b/config/src/main/resources/META-INF/schema.sql @@ -194,4 +194,4 @@ CREATE TABLE permissions ( INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); -INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN'); +INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN'); diff --git a/console/src/main/resources/META-INF/schema.sql b/console/src/main/resources/META-INF/schema.sql index 5842a2267..f0a19931b 100644 --- a/console/src/main/resources/META-INF/schema.sql +++ b/console/src/main/resources/META-INF/schema.sql @@ -193,4 +193,4 @@ CREATE TABLE permissions ( INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); -INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN'); +INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN'); diff --git a/test/src/test/java/com/alibaba/nacos/test/base/HttpClient4Test.java b/test/src/test/java/com/alibaba/nacos/test/base/HttpClient4Test.java index e4ef176e7..b92c495d6 100644 --- a/test/src/test/java/com/alibaba/nacos/test/base/HttpClient4Test.java +++ b/test/src/test/java/com/alibaba/nacos/test/base/HttpClient4Test.java @@ -1,3 +1,18 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.nacos.test.base; import org.springframework.beans.factory.annotation.Autowired; diff --git a/test/src/test/java/com/alibaba/nacos/test/core/auth/ConfigAuth_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/core/auth/ConfigAuth_ITCase.java index 41d911a03..86effc6e8 100644 --- a/test/src/test/java/com/alibaba/nacos/test/core/auth/ConfigAuth_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/core/auth/ConfigAuth_ITCase.java @@ -104,6 +104,7 @@ public class ConfigAuth_ITCase extends AuthBase { iconfig = NacosFactory.createConfigService(properties); final String content = "test" + System.currentTimeMillis(); + System.out.println(content); iconfig.addListener(dataId, group, new AbstractConfigChangeListener() { @Override @@ -130,7 +131,8 @@ public class ConfigAuth_ITCase extends AuthBase { String res = iconfig.getConfig(dataId, group, TIME_OUT); Assert.assertEquals(content, res); - latch.await(); + latch.await(5L, TimeUnit.SECONDS); + Assert.assertEquals( 0, latch.getCount()); } @Test @@ -224,7 +226,9 @@ public class ConfigAuth_ITCase extends AuthBase { String res = iconfig.getConfig(dataId, group, TIME_OUT); Assert.assertEquals(content, res); - latch.await(); + latch.await(5L, TimeUnit.SECONDS); + + Assert.assertEquals(0, latch.getCount()); result = iconfig.removeConfig(dataId, group); Assert.assertTrue(result); diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/CPInstancesAPI_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/CPInstancesAPI_ITCase.java index 533865c96..00ee8bf6d 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/CPInstancesAPI_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/CPInstancesAPI_ITCase.java @@ -119,7 +119,7 @@ public class CPInstancesAPI_ITCase { * @TestStep : * @ExpectResult : */ - @Test(expected = AssertionError.class) + @Test public void registerInstance_ephemeral_false() throws Exception { String serviceName = NamingBase.randomDomainName(); namingServiceCreate(serviceName, TEST_NAMESPACE_1, TEST_GROUP_1); @@ -174,7 +174,7 @@ public class CPInstancesAPI_ITCase { * @TestStep : * @ExpectResult : */ - @Test(expected = AssertionError.class) + @Test public void deleteService_hasInstace() throws Exception { String serviceName = NamingBase.randomDomainName(); namingServiceCreate(serviceName, TEST_NAMESPACE_1); diff --git a/test/src/test/resources/schema.sql b/test/src/test/resources/schema.sql index 5842a2267..f0a19931b 100644 --- a/test/src/test/resources/schema.sql +++ b/test/src/test/resources/schema.sql @@ -193,4 +193,4 @@ CREATE TABLE permissions ( INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); -INSERT INTO roles (username, role) VALUES ('nacos', 'GLOBAL_ADMIN'); +INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');