Replace zuul proxy with spring cloud gateway 2.x. in webapp module. (#7220)
This commit is contained in:
parent
156678a8bf
commit
0efc733901
|
|
@ -30,6 +30,7 @@ env:
|
|||
TAG: ${{ github.sha }}
|
||||
SCRIPTS_DIR: test/e2e-mesh/e2e-istio/scripts
|
||||
SW_OAP_BASE_IMAGE: openjdk:11-jdk
|
||||
SW_KUBERNETES_COMMIT_SHA: 6d5897616ce30ebb1706c0cf566ac36f733d93e0
|
||||
|
||||
concurrency:
|
||||
group: e2e-istio-${{ github.event.pull_request.number || github.ref }}
|
||||
|
|
@ -95,7 +96,7 @@ jobs:
|
|||
run: |
|
||||
git clone https://github.com/apache/skywalking-kubernetes.git
|
||||
cd skywalking-kubernetes
|
||||
git reset --hard 2fdcdc3bb39496bf49626755e8f60c998be5f587
|
||||
git reset --hard $SW_KUBERNETES_COMMIT_SHA
|
||||
cd chart
|
||||
mkdir -p skywalking/files/conf.d/oap/ && cp ../../test/e2e/e2e-test/src/test/resources/metadata-service-mapping.yaml skywalking/files/conf.d/oap/metadata-service-mapping.yaml
|
||||
helm dep up skywalking
|
||||
|
|
@ -237,7 +238,7 @@ jobs:
|
|||
run: |
|
||||
git clone https://github.com/apache/skywalking-kubernetes.git
|
||||
cd skywalking-kubernetes
|
||||
git reset --hard dd749f25913830c47a97430618cefc4167612e75
|
||||
git reset --hard $SW_KUBERNETES_COMMIT_SHA
|
||||
cd chart
|
||||
helm dep up skywalking
|
||||
helm -n istio-system install skywalking skywalking \
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ Release Notes.
|
|||
rather than first time. This makes sure hot data never gets removed unexpectedly.
|
||||
* Support session expired threshold configurable.
|
||||
* Fix InfluxDB storage-plugin Metrics#multiGet issue.
|
||||
* Replace zuul proxy with spring cloud gateway 2.x. in webapp module.
|
||||
|
||||
#### UI
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
~
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>apm</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
|
|
@ -29,18 +30,17 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.boot.version>1.5.22.RELEASE</spring.boot.version>
|
||||
<spring.boot.version>2.4.8</spring.boot.version>
|
||||
<log4j.version>2.6.2</log4j.version>
|
||||
<gson.version>2.8.2</gson.version>
|
||||
<apache-httpclient.version>4.5.3</apache-httpclient.version>
|
||||
<spring-cloud-dependencies.version>Edgware.SR1</spring-cloud-dependencies.version>
|
||||
<spring-cloud-dependencies.version>2020.0.3</spring-cloud-dependencies.version>
|
||||
<frontend-maven-plugin.version>1.11.0</frontend-maven-plugin.version>
|
||||
<logback-classic.version>1.2.3</logback-classic.version>
|
||||
<jackson-version>2.12.2</jackson-version>
|
||||
<yaml.version>1.28</yaml.version>
|
||||
<netty.version>4.1.65.Final</netty.version>
|
||||
<tomcat.version>8.5.66</tomcat.version>
|
||||
|
||||
<ui.path>${project.parent.basedir}/skywalking-ui</ui.path>
|
||||
</properties>
|
||||
|
|
@ -59,10 +59,15 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
|
|
@ -80,11 +85,6 @@
|
|||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
|
@ -95,10 +95,6 @@
|
|||
<artifactId>httpclient</artifactId>
|
||||
<version>${apache-httpclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
@ -109,21 +105,6 @@
|
|||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${yaml.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-handler</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<version>${tomcat.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-websocket</artifactId>
|
||||
<version>${tomcat.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
|
@ -212,7 +193,9 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
<goal>
|
||||
repackage
|
||||
</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
# 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
|
||||
# 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
|
||||
#
|
||||
|
|
@ -17,10 +16,30 @@
|
|||
server:
|
||||
port: 8080
|
||||
|
||||
collector:
|
||||
path: /graphql
|
||||
ribbon:
|
||||
ReadTimeout: 10000
|
||||
# Point to all backend's restHost:restPort, split by ,
|
||||
listOfServers: 127.0.0.1:12800
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: oap-route
|
||||
uri: lb://oap-service
|
||||
predicates:
|
||||
- Path=/graphql/**
|
||||
discovery:
|
||||
client:
|
||||
simple:
|
||||
instances:
|
||||
oap-service:
|
||||
- uri: http://127.0.0.1:12800
|
||||
# - uri: http://<oap-host-1>:<oap-port1>
|
||||
# - uri: http://<oap-host-2>:<oap-port2>
|
||||
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
|
||||
web:
|
||||
resources:
|
||||
add-mappings: true
|
||||
|
||||
management:
|
||||
server:
|
||||
base-path: /manage
|
||||
|
|
|
|||
|
|
@ -20,15 +20,10 @@ package org.apache.skywalking.apm.webapp;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableZuulProxy
|
||||
public class ApplicationStartUp extends SpringBootServletInitializer {
|
||||
|
||||
public class ApplicationStartUp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ApplicationStartUp.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* 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.proxy;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
/**
|
||||
* Additional MVC Configuration.
|
||||
*/
|
||||
@Configuration
|
||||
public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/index.html").addResourceLocations("classpath:/public/index.html");
|
||||
registry.addResourceHandler("/css/**").addResourceLocations("classpath:/public/css/");
|
||||
registry.addResourceHandler("/img/**").addResourceLocations("classpath:/public/img/");
|
||||
registry.addResourceHandler("/js/**").addResourceLocations("classpath:/public/js/");
|
||||
registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/public/favicon.ico");
|
||||
registry.addResourceHandler("/logo.png").addResourceLocations("classpath:/public/logo.png");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* 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.proxy;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* NotFoundHandler handles the single page application url routing.
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class NotFoundHandler {
|
||||
@ExceptionHandler(NoHandlerFoundException.class)
|
||||
public ResponseEntity<String> renderDefaultPage() {
|
||||
try {
|
||||
String body = StreamUtils.copyToString(new ClassPathResource("/public/index.html").getInputStream(), Charset
|
||||
.defaultCharset());
|
||||
return ResponseEntity.ok().contentType(MediaType.TEXT_HTML).body(body);
|
||||
} catch (final IOException e) {
|
||||
LoggerFactory.getLogger(NotFoundHandler.class).error("err", e);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("There was an error completing the action.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* 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.proxy;
|
||||
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.springframework.cloud.netflix.zuul.filters.support.FilterConstants.PRE_DECORATION_FILTER_ORDER;
|
||||
|
||||
/**
|
||||
* Rewrite url to rewritePath
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "collector")
|
||||
public class RewritePathFilter extends ZuulFilter {
|
||||
|
||||
private static final String REQUEST_URI = "requestURI";
|
||||
|
||||
private static final int ORDER = PRE_DECORATION_FILTER_ORDER + 2;
|
||||
|
||||
private String path;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int filterOrder() {
|
||||
return ORDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filterType() {
|
||||
return "pre";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
RequestContext ctx = RequestContext.getCurrentContext();
|
||||
return ctx.containsKey(REQUEST_URI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
RequestContext ctx = RequestContext.getCurrentContext();
|
||||
ctx.set(REQUEST_URI, path);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,28 +17,30 @@
|
|||
server:
|
||||
port: 8080
|
||||
|
||||
zuul:
|
||||
ignoredServices: '*'
|
||||
routes:
|
||||
api:
|
||||
path: /graphql
|
||||
serviceId: collector
|
||||
login:
|
||||
path: /login/account
|
||||
serviceId: collector
|
||||
|
||||
collector:
|
||||
path: /graphql
|
||||
ribbon:
|
||||
# Point to all backend's restHost:restPort, split by ,
|
||||
listOfServers: 127.0.0.1:12800
|
||||
|
||||
spring:
|
||||
resources:
|
||||
add-mappings: false
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: oap-route
|
||||
uri: lb://oap-service
|
||||
predicates:
|
||||
- Path=/graphql/**
|
||||
discovery:
|
||||
client:
|
||||
simple:
|
||||
instances:
|
||||
oap-service:
|
||||
- uri: http://127.0.0.1:12800
|
||||
# - uri: http://<oap-host-1>:<oap-port1>
|
||||
# - uri: http://<oap-host-2>:<oap-port2>
|
||||
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
|
||||
|
||||
web:
|
||||
resources:
|
||||
add-mappings: true
|
||||
|
||||
management:
|
||||
# Customizing the management endpoint paths
|
||||
context-path: /manage
|
||||
server:
|
||||
base-path: /manage
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* 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 java.io.IOException;
|
||||
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 static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +251,9 @@ The text of each license is the standard Apache 2.0 license.
|
|||
Joda-Time 2.10.5: http://www.joda.org/joda-time/ , Apache 2.0
|
||||
Joda-Convert 2.2.1: http://www.joda.org/joda-convert/ , Apache 2.0
|
||||
Spring Framework 4.3.14.RELEASE: https://github.com/spring-projects/spring-framework, Apache 2.0
|
||||
Spring Boot 1.5.22.RELEASE: https://spring.io/, Apache 2.0
|
||||
Spring Boot 2.4.8: https://spring.io/, Apache 2.0
|
||||
Spring Cloud Gateway 3.0.3: https://spring.io/projects/spring-cloud, Apache-2.0
|
||||
Spring Cloud Load Balancer 3.0.3: https://spring.io/projects/spring-cloud, Apache-2.0
|
||||
Spring Cloud Config 1.4.1: https://github.com/spring-cloud/spring-cloud-config, Apache-2.0
|
||||
Spring Cloud Netflix Zuul 1.3.0: https://github.com/spring-cloud/spring-cloud-netflix, Apache 2.0
|
||||
Apache: commons-logging 1.1.3: https://github.com/apache/commons-logging, Apache 2.0
|
||||
|
|
@ -270,7 +272,6 @@ The text of each license is the standard Apache 2.0 license.
|
|||
Apache: commons-io 2.4: https://github.com/apache/commons-io, Apache 2.0
|
||||
Apache: commons-compress 1.20: https://github.com/apache/commons-compress, Apache 2.0
|
||||
Apache: commons-collections4 4.4: https://mvnrepository.com/artifact/org.apache.commons/commons-collections4, Apache 2.0
|
||||
Apache: tomcat 8.5.66: https://github.com/apache/tomcat/tree/trunk, Apache 2.0
|
||||
Apache: freemarker 2.3.28: https://github.com/apache/freemarker, Apache 2.0
|
||||
netty 4.1.65: https://github.com/netty/netty/blob/4.1/LICENSE.txt, Apache 2.0
|
||||
annotations 13.0: http://www.jetbrains.org, Apache 2.0
|
||||
|
|
@ -302,7 +303,6 @@ The text of each license is the standard Apache 2.0 license.
|
|||
rxnetty 0.4.9: https://github.com/ReactiveX/rxnetty, Apache 2.0
|
||||
servo 0.10.1: https://github.com/Netflix/servo, Apache 2.0
|
||||
validation-api 1.1.0.Final: http://beanvalidation.org/licensing/, Apache 2.0
|
||||
zuul-core 1.3.0: https://github.com/Netflix/zuul, Apache 2.0
|
||||
HikariCP 3.1.0: https://github.com/brettwooldridge/HikariCP, Apache 2.0
|
||||
zipkin 2.9.1: https://github.com/openzipkin/zipkin, Apache 2.0
|
||||
sharding-jdbc-core 2.0.3: https://github.com/sharding-sphere/sharding-sphere, Apache 2.0
|
||||
|
|
|
|||
|
|
@ -61,4 +61,4 @@ services:
|
|||
ports:
|
||||
- 8080:8080
|
||||
environment:
|
||||
SW_OAP_ADDRESS: oap:12800
|
||||
SW_OAP_ADDRESS: http://oap:12800
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ FROM adoptopenjdk/openjdk8:alpine
|
|||
|
||||
ENV DIST_NAME=apache-skywalking-apm-bin \
|
||||
JAVA_OPTS=" -Xms256M " \
|
||||
SW_OAP_ADDRESS="127.0.0.1:12800" \
|
||||
SW_TIMEOUT="20000"
|
||||
SW_OAP_ADDRESS="http://127.0.0.1:12800"
|
||||
|
||||
COPY "$DIST_NAME.tar.gz" /
|
||||
|
||||
RUN set -ex; \
|
||||
apk add bash; \
|
||||
tar -xzf "$DIST_NAME.tar.gz"; \
|
||||
rm -rf "$DIST_NAME.tar.gz"; \
|
||||
rm -rf "$DIST_NAME/config"; \
|
||||
|
|
@ -37,4 +37,4 @@ COPY logback.xml webapp/
|
|||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["sh", "docker-entrypoint.sh"]
|
||||
ENTRYPOINT ["bash", "docker-entrypoint.sh"]
|
||||
|
|
@ -20,7 +20,12 @@ set -e
|
|||
|
||||
export LOGGING_CONFIG="webapp/logback.xml"
|
||||
|
||||
[[ ! -z "$SW_OAP_ADDRESS" ]] && export COLLECTOR_RIBBON_LISTOFSERVERS=${SW_OAP_ADDRESS} && echo "COLLECTOR_RIBBON_LISTOFSERVERS=$COLLECTOR_RIBBON_LISTOFSERVERS"
|
||||
[[ ! -z "$SW_TIMEOUT" ]] && export COLLECTOR_RIBBON_READTIMEOUT=${SW_TIMEOUT} && echo "COLLECTOR_RIBBON_READTIMEOUT=$COLLECTOR_RIBBON_READTIMEOUT"
|
||||
if [[ ! -z "$SW_OAP_ADDRESS" ]]; then
|
||||
address_arr=(${SW_OAP_ADDRESS//,/ })
|
||||
for i in "${!address_arr[@]}"
|
||||
do
|
||||
JAVA_OPTS="${JAVA_OPTS} -Dspring.cloud.discovery.client.simple.instances.oap-service[$i].uri=${address_arr[$i]}"
|
||||
done
|
||||
fi
|
||||
|
||||
exec java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -jar webapp/skywalking-webapp.jar "$@"
|
||||
exec java ${JAVA_OPTS} -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -jar webapp/skywalking-webapp.jar "$@"
|
||||
|
|
|
|||
|
|
@ -13,13 +13,22 @@ Setting file of UI is `webapp/webapp.yml` in distribution package. It is consti
|
|||
```yaml
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
collector:
|
||||
path: /graphql
|
||||
ribbon:
|
||||
ReadTimeout: 10000
|
||||
# Point to all backend's restHost:restPort, split by ,
|
||||
listOfServers: 10.2.34.1:12800,10.2.34.2:12800
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: oap-route
|
||||
uri: lb://oap-service
|
||||
predicates:
|
||||
- Path=/graphql/**
|
||||
discovery:
|
||||
client:
|
||||
simple:
|
||||
instances:
|
||||
oap-service:
|
||||
# Point to all backend's restHost:restPort, split by URI arrays.
|
||||
- uri: http://127.0.0.1:12800
|
||||
- uri: http://instance-2:12800
|
||||
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ services:
|
|||
oap:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
SW_OAP_ADDRESS: oap:12800
|
||||
SW_OAP_ADDRESS: http://oap:12800
|
||||
expose:
|
||||
- '8080'
|
||||
image: skywalking/ui:latest
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ services:
|
|||
networks:
|
||||
- e2e
|
||||
environment:
|
||||
- SW_OAP_ADDRESS=oap:12800
|
||||
- SW_OAP_ADDRESS=http://oap:12800
|
||||
|
||||
provider:
|
||||
build:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ services:
|
|||
file: ../base-compose.yml
|
||||
service: ui
|
||||
environment:
|
||||
- SW_OAP_ADDRESS=oap1:12800,oap2:12800
|
||||
- SW_OAP_ADDRESS=http://oap1:12800,http://oap2:12800
|
||||
depends_on:
|
||||
oap1:
|
||||
condition: service_healthy
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ services:
|
|||
file: ../base-compose.yml
|
||||
service: ui
|
||||
environment:
|
||||
- SW_OAP_ADDRESS=oap1:12800,oap2:12800
|
||||
- SW_OAP_ADDRESS=http://oap1:12800,http://oap2:12800
|
||||
depends_on:
|
||||
oap1:
|
||||
condition: service_healthy
|
||||
|
|
|
|||
Loading…
Reference in New Issue