Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Oct 9, 2019
2 parents e4571e6 + 72b722a commit 5e27b74
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile-Agent-Test
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pipeline {

stage('Compile plugin-test tools Codes') {
steps {
sh './mvnw -f test/plugin/pom.xml -Pagent clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build'
sh './mvnw -f test/plugin/pom.xml clean package -DskipTests -Dbuild_id=${BUILD_ID} docker:build'
}
}

Expand Down
13 changes: 8 additions & 5 deletions docker/oap/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ generateClusterNacos() {
cluster:
nacos:
serviceName: \${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
namespace: \${SW_CLUSTER_NACOS_NAMESPACE:""}
hostPort: \${SW_CLUSTER_NACOS_HOST_PORT:nacos:8848}
EOT
}
Expand Down Expand Up @@ -163,15 +164,17 @@ generateConfigurationNacos() {
configuration:
nacos:
# Nacos Server Host
serverAddr: \${SW_CONFIGURATION_NACO_SERVER_ADDR:naco}
serverAddr: \${SW_CONFIGURATION_NACOS_SERVER_ADDR:nacos}
# Nacos Server Port
port: \${SW_CONFIGURATION_NACO_PORT:8848}
port: \${SW_CONFIGURATION_NACOS_PORT:8848}
# Nacos Configuration Group
group: \${SW_CONFIGURATION_NACO_GROUP:skywalking}
group: \${SW_CONFIGURATION_NACOS_GROUP:skywalking}
# Nacos Configuration namespace
namespace: \${SW_CONFIGURATION_NACOS_NAMESPACE:""}
# Unit seconds, sync period. Default fetch every 60 seconds.
period : \${SW_CONFIGURATION_NACO_PERIOD:5}
period : \${SW_CONFIGURATION_NACOS_PERIOD:5}
# the name of current cluster, set the name if you want to upstream system known.
clusterName: \${SW_CONFIGURATION_NACO_CLUSTER_NAME:default}
clusterName: \${SW_CONFIGURATION_NACOS_CLUSTER_NAME:default}
EOT
}

Expand Down
2 changes: 2 additions & 0 deletions docs/en/setup/backend/backend-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ cluster:
serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
# Nacos cluster nodes, example: 10.0.0.1:8848,10.0.0.2:8848,10.0.0.3:8848
hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848}
# Nacos Configuration namespace
namespace: ${SW_CLUSTER_NACOS_NAMESPACE:"public"}
```

## Etcd
Expand Down
2 changes: 2 additions & 0 deletions docs/en/setup/backend/dynamic-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ configuration:
port: 8848
# Nacos Configuration Group
group: 'skywalking'
# Nacos Configuration namespace
namespace: ''
# Unit seconds, sync period. Default fetch every 60 seconds.
period : 60
# the name of current cluster, set the name if you want to upstream system known.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
public class ClusterModuleNacosConfig extends ModuleConfig {
@Setter @Getter private String serviceName;
@Setter @Getter private String hostPort;
@Setter @Getter private String namespace = "public";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.skywalking.oap.server.cluster.plugin.nacos;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import org.apache.skywalking.oap.server.core.CoreModule;
Expand All @@ -27,6 +27,8 @@
import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.library.module.*;

import java.util.Properties;

/**
* @author caoyixiong
*/
Expand Down Expand Up @@ -58,8 +60,11 @@ public ModuleConfig createConfigBeanIfAbsent() {
@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {
try {
namingService = NamingFactory.createNamingService(config.getHostPort());
} catch (NacosException e) {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, config.getHostPort());
properties.put(PropertyKeyConst.NAMESPACE, config.getNamespace());
namingService = NamingFactory.createNamingService(properties);
} catch (Exception e) {
throw new ModuleStartException(e.getMessage(), e);
}
NacosCoordinator coordinator = new NacosCoordinator(namingService, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.skywalking.oap.server.cluster.plugin.nacos;

import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import org.apache.skywalking.oap.server.core.CoreModule;
Expand All @@ -32,6 +33,9 @@
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;

import java.util.Properties;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -79,13 +83,17 @@ public void prepare() throws Exception {
nacosConfig.setServiceName(SERVICE_NAME);
Whitebox.setInternalState(provider, "config", nacosConfig);
NamingService namingService = mock(NamingService.class);
PowerMockito.when(NamingFactory.createNamingService("10.0.0.1:1000,10.0.0.2:1001")).thenReturn(namingService);

Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "10.0.0.1:1000,10.0.0.2:1001");

PowerMockito.when(NamingFactory.createNamingService(properties)).thenReturn(namingService);
provider.prepare();
ArgumentCaptor<String> addressCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Properties> addressCaptor = ArgumentCaptor.forClass(Properties.class);
PowerMockito.verifyStatic();
NamingFactory.createNamingService(addressCaptor.capture());
String data = addressCaptor.getValue();
assertEquals("10.0.0.1:1000,10.0.0.2:1001", data);
Properties data = addressCaptor.getValue();
assertEquals("10.0.0.1:1000,10.0.0.2:1001", data.getProperty(PropertyKeyConst.SERVER_ADDR));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.skywalking.oap.server.configuration.nacos;

import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.PropertyKeyConst;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
Expand Down Expand Up @@ -53,7 +54,8 @@ public NacosConfigWatcherRegister(NacosServerSettings settings) throws NacosExce
final String serverAddr = this.settings.getServerAddr();

final Properties properties = new Properties();
properties.put("serverAddr", serverAddr + ":" + port);
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr + ":" + port);
properties.put(PropertyKeyConst.NAMESPACE, settings.getNamespace());
this.configService = NacosFactory.createConfigService(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,22 @@

package org.apache.skywalking.oap.server.configuration.nacos;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.skywalking.oap.server.library.module.ModuleConfig;

/**
* @author kezhenxu94
*/
@Getter
@Setter
@ToString
public class NacosServerSettings extends ModuleConfig {
private String clusterName = "default";
private String namespace = "";
private String serverAddr;
private int port = 8848;
private String group;
private int period = 60;

public String getClusterName() {
return clusterName;
}

public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}

public String getServerAddr() {
return serverAddr;
}

public void setServerAddr(String serverAddr) {
this.serverAddr = serverAddr;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public String getGroup() {
return group;
}

public void setGroup(String group) {
this.group = group;
}

public int getPeriod() {
return period;
}

public void setPeriod(int period) {
this.period = period;
}

public String toString() {
return "NacosServerSettings(clusterName=" + this.getClusterName()
+ ", serverAddr=" + this.getServerAddr()
+ ", group=" + this.getGroup()
+ ", period=" + this.getPeriod() + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void shouldReadConfigs() throws NacosException {

final NacosServerSettings mockSettings = mock(NacosServerSettings.class);
when(mockSettings.getGroup()).thenReturn(group);
when(mockSettings.getNamespace()).thenReturn("");

final NacosConfigWatcherRegister mockRegister = spy(new NacosConfigWatcherRegister(mockSettings));
final ConfigService mockConfigService = mock(ConfigService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ configuration:
port: ${nacos.port}
# Nacos Configuration Group
group: 'skywalking'
# Nacos Configuration namespace
namespace: ''
# Unit seconds, sync period. Default fetch every 60 seconds.
period: 1
# the name of current cluster, set the name if you want to upstream system known.
Expand Down
4 changes: 4 additions & 0 deletions oap-server/server-starter/src/main/assembly/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ cluster:
# nacos:
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
# hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848}
# # Nacos Configuration namespace
# namespace: 'public'
# etcd:
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
# etcd cluster nodes, example: 10.0.0.1:2379,10.0.0.2:2379,10.0.0.3:2379
Expand Down Expand Up @@ -152,6 +154,8 @@ configuration:
# port: 8848
# # Nacos Configuration Group
# group: 'skywalking'
# # Nacos Configuration namespace
# namespace: ''
# # Unit seconds, sync period. Default fetch every 60 seconds.
# period : 60
# # the name of current cluster, set the name if you want to upstream system known.
Expand Down
4 changes: 4 additions & 0 deletions oap-server/server-starter/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ cluster:
# hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
# nacos:
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
# # Nacos Configuration namespace
# namespace: ${SW_CLUSTER_NACOS_NAMESPACE:"public"}
# hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848}
# etcd:
# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
Expand Down Expand Up @@ -164,6 +166,8 @@ configuration:
# port: 8848
# # Nacos Configuration Group
# group: 'skywalking'
# # Nacos Configuration namespace
# namespace: ''
# # Unit seconds, sync period. Default fetch every 60 seconds.
# period : 5
# # the name of current cluster, set the name if you want to upstream system known.
Expand Down
32 changes: 25 additions & 7 deletions test/plugin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,43 @@
# limitations under the License.

home="$(cd "$(dirname $0)"; pwd)"
scenario_name="empty"
scenario_name=""
parallel_run_size=1
force_build="off"
build_id="latest"


mvnw=${home}/../../mvnw
agent_home=${home}"/../../skywalking-agent"
scenarios_home="${home}/scenarios"

_positionals=()

print_help() {
echo "Usage: run.sh [OPTION] SCENARIO [SCENARIO]"
echo -e "\t-f, --force_build \t\t do force to build Plugin-Test tools and images"
echo -e "\t--build_id, \t\t\t specify Plugin_Test's image tag. Defalt: latest"
echo -e "\t--parallel_run_size, \t\t parallel size of test cases. Default: 1"
}

parse_commandline() {
_positionals_count=0
while test $# -gt 0
do
_key="$1"
case "$_key" in
-f|--force_build)
force_build="on"
shift
;;
--build_id)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'."
build_id="$2"
shift
;;
--build_id=*)
build_id="${_key##--build_id=}"
;;
--parallel_run_size)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
test $# -lt 2 && exitWithMessage "Missing value for the optional argument '$_key'."
parallel_run_size="$2"
shift
;;
Expand Down Expand Up @@ -93,9 +104,15 @@ waitForAvailable() {
exitAndClean 1
fi
}
parse_commandline "$@"

start_stamp=`date +%s` ### start
parse_commandline "$@"

if [[ ! -d ${agent_home} ]]; then
echo "[WARN] SkyWalking Agent not exists"
${mvnw} -f ${home}/../../pom.xml -Pagent -DskipTests clean package
fi
[[ "$force_build" == "on" ]] && ${mvnw} -f ${home}/pom.xml clean package -DskipTests -Dbuild_id=${build_id} docker:build

workspace="${home}/workspace/${scenario_name}"
task_state_house="${workspace}/.states"
Expand All @@ -104,7 +121,8 @@ mkdir -p ${task_state_house}

plugin_autotest_helper="${home}/dist/plugin-autotest-helper.jar"
if [[ ! -f ${plugin_autotest_helper} ]]; then
exitWithMessage "plugin autotest helper not exist!"
exitWithMessage "Plugin autotest tools not exists, Please re-try it with '-f'"
print_helper
fi

echo "start submit job"
Expand Down

0 comments on commit 5e27b74

Please sign in to comment.