Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-sheng committed Oct 7, 2019
2 parents 4a88cf3 + e3ecf51 commit b30de5f
Show file tree
Hide file tree
Showing 54 changed files with 1,930 additions and 196 deletions.
5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pipeline {
))
timestamps()
skipStagesAfterUnstable()
timeout(time: 5, unit: 'HOURS')
}

environment {
Expand All @@ -36,7 +37,7 @@ pipeline {
parallel {
stage('JDK 1.8 on Linux') {
agent {
label 'xenial'
label 'skywalking'
}

tools {
Expand All @@ -63,7 +64,7 @@ pipeline {

stage('Test & Report') {
steps {
sh './mvnw -P"agent,backend,ui,dist,CI-with-IT" org.jacoco:jacoco-maven-plugin:0.8.3:prepare-agent clean install org.jacoco:jacoco-maven-plugin:0.8.3:report'
sh './mvnw -P"agent,backend,ui,dist,CI-with-IT" -DrepoToken=${COVERALLS_REPO_TOKEN} -DpullRequest=${ghprbPullLink} clean cobertura:cobertura verify coveralls:report install'
sh './mvnw javadoc:javadoc -Dmaven.test.skip=true'
}
}
Expand Down
7 changes: 6 additions & 1 deletion Jenkinsfile-E2E
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

pipeline {
agent {
label 'xenial'
label 'skywalking'
}

options {
timestamps()
timeout(time: 5, unit: 'HOURS')
}

tools {
Expand Down
4 changes: 2 additions & 2 deletions apm-dist/release-docs/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ The text of each license is the standard Apache 2.0 license.
Google: grpc 1.15.1: https://grpc.io/ , Apache 2.0
Google: gprc-java 1.14.0: https://github.com/grpc/grpc-java, Apache 2.0
Google: gprc-java 1.15.1: https://github.com/grpc/grpc-java, Apache 2.0
Google: guava 20.0: https://github.com/google/guava , Apache 2.0
Google: guava 23.1: https://github.com/google/guava , Apache 2.0
Google: guice 4.1.0: https://github.com/google/guice , Apache 2.0
Google: gson 2.8.1: https://github.com/google/gson , Apache 2.0
Google: opencensus-java 0.12.3: https://github.com/census-instrumentation/opencensus-java , Apache 2.0
Expand Down Expand Up @@ -275,7 +275,7 @@ The text of each license is the standard Apache 2.0 license.
netty 5.5.0: https://github.com/netty/netty/blob/4.1/LICENSE.txt, Apache 2.0
annotations 13.0: http://www.jetbrains.org, Apache 2.0
compiler 0.9.3: https://github.com/spullara/mustache.java, Apache 2.0
error_prone_annotations 2.0.19: https://github.com/google/error-prone, Apache 2.0
error_prone_annotations 2.0.18: https://github.com/google/error-prone, Apache 2.0
hppc 0.7.1: https://github.com/carrotsearch/hppc, Apache 2.0
instrumentation-api 0.4.3: https://github.com/google/instrumentation-java, Apache 2.0
jackson-annotations 2.8.0: https://github.com/FasterXML/jackson-annotations, Apache 2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.api.network.trace.component.command;

import org.apache.skywalking.apm.network.common.Command;
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
import org.apache.skywalking.apm.network.trace.component.command.ServiceResetCommand;
import org.junit.Assert;
import org.junit.Test;

/**
* @author jsbxyyx
*/
public class ServiceResetCommandTest {

@Test
public void serialize_Serialize_SerialNumberIsaa() throws Exception {
ServiceResetCommand command = new ServiceResetCommand("aa");
Command.Builder builder = command.serialize();

Assert.assertEquals(ServiceResetCommand.NAME, builder.getCommand());
Assert.assertEquals("aa", builder.getArgs(0).getValue());
}

@Test
public void deserialize_NullPointerException_CommandKeyIsNotSerialNumber() throws Exception {
ServiceResetCommand command = new ServiceResetCommand("aa");

Command command1 = Command.newBuilder()
.addArgs(KeyStringValuePair.newBuilder().setKey("aa").setValue("aa").build())
.build();
boolean exception = false;
try {
command.deserialize(command1);
} catch (NullPointerException e) {
exception = true;
}
Assert.assertEquals(true, exception);
}

@Test
public void deserialize_SerialNumberCompare_CommandKeyIsSerialNumberValueIsaa() throws Exception {
ServiceResetCommand command = new ServiceResetCommand("aa");

Command command2 = Command.newBuilder()
.addArgs(KeyStringValuePair.newBuilder().setKey("SerialNumber").setValue("aa").build())
.build();
ServiceResetCommand deserialize2 = command.deserialize(command2);
Assert.assertEquals("aa", deserialize2.getSerialNumber());
}

@Test
public void deserialize_SerializeAndDeserialize_SerialNumberValueIsaa() throws Exception {
ServiceResetCommand command = new ServiceResetCommand("aa");
Command.Builder builder = command.serialize();
Command command3 = builder.build();
ServiceResetCommand deserialize3 = command.deserialize(command3);
Assert.assertEquals(command.getCommand(), deserialize3.getCommand());
Assert.assertEquals(command.getSerialNumber(), deserialize3.getSerialNumber());
}

}
8 changes: 8 additions & 0 deletions apm-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<apache-httpclient.version>4.5.3</apache-httpclient.version>
<spring-cloud-dependencies.version>Edgware.SR1</spring-cloud-dependencies.version>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<logback-classic.version>1.2.3</logback-classic.version>

<ui.path>${project.parent.basedir}/skywalking-ui</ui.path>
</properties>
Expand Down Expand Up @@ -94,6 +95,13 @@
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
* @author kezhenxu94
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class ApplicationContextTest {

@Test
public void contextShouldLoad() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp;

import org.apache.skywalking.apm.webapp.proxy.NotFoundHandler;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* @author kezhenxu94
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = {NotFoundHandler.class, ClassPathResource.class})
public class NotFoundHandlerTest {
@Mock
private NotFoundHandler notFoundHandler;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}

@Test
public void shouldInternalErrorWhenIndexPageIsMissing() throws Exception {
ClassPathResource mockIndexResource = mock(ClassPathResource.class);
when(mockIndexResource.getInputStream()).thenThrow(new IOException());

PowerMockito.whenNew(ClassPathResource.class)
.withArguments("/public/index.html")
.thenReturn(mockIndexResource);

when(notFoundHandler.renderDefaultPage()).thenCallRealMethod();
ResponseEntity<String> response = notFoundHandler.renderDefaultPage();
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.webapp;

import org.apache.skywalking.apm.webapp.proxy.NotFoundHandler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.CoreMatchers.containsString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
* @author kezhenxu94
*/
@WebMvcTest
@RunWith(SpringRunner.class)
public class WebAppTest {
@Autowired
private MockMvc mvc;
@MockBean
private NotFoundHandler notFoundHandler;

@Test
public void shouldGetStaticResources() throws Exception {
when(notFoundHandler.renderDefaultPage()).thenCallRealMethod();

mvc.perform(get("/index.html"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string(containsString("<title>SkyWalking</title>")));

verify(notFoundHandler, never()).renderDefaultPage();
}

@Test
public void shouldRedirectToIndexWhenResourcesIsAbsent() throws Exception {
when(notFoundHandler.renderDefaultPage()).thenCallRealMethod();

mvc.perform(get("/absent.html"))
.andDo(print())
.andExpect(status().isOk());

verify(notFoundHandler, only()).renderDefaultPage();
}
}
5 changes: 1 addition & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This folder contains Docker files for SkyWalking developers to build images manually. If you want to start SkyWalking backend server with docker-compose for your integration, please visit https://github.com/apache/skywalking-docker repository.

You can find docker images on hub.docker.com along with user's guide if you want to start them individually.

https://hub.docker.com/r/apache/skywalking-oap-server
https://hub.docker.com/r/apache/skywalking-ui
You can use `Makefile` located at root folder to build docker image with current code base. The enviroment variable `HUB` and `TAG` will help you build the image with dedicated tag.
12 changes: 12 additions & 0 deletions docker/oap/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ configuration:
EOT
}

generateConfigurationConsul() {
cat <<EOT >> ${var_application_file}
configuration:
consul:
# Consul host and ports, separated by comma, e.g. 1.2.3.4:8500,2.3.4.5:8500
hostAndPorts: \${SW_CONFIGURATION_CONSUL_ADDRESS:127.0.0.1:8500}
# Sync period in seconds. Defaults to 60 seconds.
period: \${SW_CONFIGURATION_CONSUL_PERIOD:60}
EOT
}

generateTelemetryNone() {
cat <<EOT >> ${var_application_file}
telemetry:
Expand Down Expand Up @@ -346,6 +357,7 @@ EOT
apollo) generateConfigurationApollo;;
nacos) generateConfigurationNacos;;
zookeeper) generateConfigurationZookeeper;;
consul) generateConfigurationConsul;;
esac

cat <<EOT >> ${var_application_file}
Expand Down
Loading

0 comments on commit b30de5f

Please sign in to comment.