未验证 提交 1601cc10 编写于 作者: 静夜思朝颜's avatar 静夜思朝颜 提交者: GitHub

Support `java` -> `nginx` -> `java` e2e test, and v3 protocol (#4637)

上级 31385159
...@@ -72,9 +72,8 @@ jobs: ...@@ -72,9 +72,8 @@ jobs:
run: make docker run: make docker
- name: Copy dist package - name: Copy dist package
run: cp -R dist test/e2e/ run: cp -R dist test/e2e/
# TODO, LUA hasn't followed the v3 protocol - name: Nginx Lua
# - name: Nginx Lua run: ./mvnw --batch-mode -f test/e2e/pom.xml -am -DfailIfNoTests=false verify -Dit.test=org.apache.skywalking.e2e.LuaE2E
# run: ./mvnw --batch-mode -f test/e2e/pom.xml -am -DfailIfNoTests=false verify -Dit.test=org.apache.skywalking.e2e.LuaE2E
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
if: failure() if: failure()
with: with:
......
/*
* 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.e2e.lua;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
@RestController
@RequiredArgsConstructor
public class LuaController {
protected final RestTemplate restTemplate = new RestTemplate();
@PostMapping("/nginx/entry/info")
private String nginxEntry(String backend) throws MalformedURLException, URISyntaxException {
final URL url = new URL("http://nginx:8080/nginx/info");
final ResponseEntity<String> response = restTemplate.postForEntity(url.toURI(), null, String.class);
return response.getBody();
}
}
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
FROM openresty/openresty FROM openresty/openresty
ENV COMMIT_HASH=9cebe51276d9a8a5b360ee1d9897e8bf803bda31 ENV COMMIT_HASH=45cf64640047a4a54619fa1d3451b4d0a65a62d6
WORKDIR /usr/share/skywalking-nginx-lua WORKDIR /usr/share/skywalking-nginx-lua
......
...@@ -42,7 +42,7 @@ services: ...@@ -42,7 +42,7 @@ services:
oap: oap:
condition: service_healthy condition: service_healthy
provider: provider-entry:
build: build:
context: ../../../ context: ../../../
dockerfile: e2e-test/docker/Dockerfile.provider dockerfile: e2e-test/docker/Dockerfile.provider
...@@ -52,6 +52,27 @@ services: ...@@ -52,6 +52,27 @@ services:
- 9090 - 9090
environment: environment:
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=oap:11800 - SW_AGENT_COLLECTOR_BACKEND_SERVICES=oap:11800
- SW_AGENT_NAME=e2e-service-entry-provider
depends_on:
oap:
condition: service_healthy
healthcheck:
test: ["CMD", "sh", "-c", "nc -z 127.0.0.1 9090"]
interval: 5s
timeout: 60s
retries: 120
provider-end:
build:
context: ../../../
dockerfile: e2e-test/docker/Dockerfile.provider
networks:
- e2e
expose:
- 9090
environment:
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=oap:11800
- SW_AGENT_NAME=e2e-service-end-provider
depends_on: depends_on:
oap: oap:
condition: service_healthy condition: service_healthy
...@@ -72,7 +93,9 @@ services: ...@@ -72,7 +93,9 @@ services:
depends_on: depends_on:
oap: oap:
condition: service_healthy condition: service_healthy
provider: # Just to make sure that the service id > provider service id provider-entry:
condition: service_healthy
provider-end:
condition: service_healthy condition: service_healthy
volumes: volumes:
- ../lua/nginx.conf:/var/nginx/conf.d/nginx.conf - ../lua/nginx.conf:/var/nginx/conf.d/nginx.conf
......
...@@ -50,7 +50,7 @@ http { ...@@ -50,7 +50,7 @@ http {
require("tracer"):start("User_Service_Name") require("tracer"):start("User_Service_Name")
} }
proxy_pass http://provider:9090/info; proxy_pass http://provider-end:9090/info;
body_filter_by_lua_block { body_filter_by_lua_block {
require("tracer"):finish() require("tracer"):finish()
......
...@@ -77,17 +77,22 @@ public class LuaE2E extends SkyWalkingTestAdapter { ...@@ -77,17 +77,22 @@ public class LuaE2E extends SkyWalkingTestAdapter {
@ContainerHostAndPort(name = "ui", port = 8080) @ContainerHostAndPort(name = "ui", port = 8080)
private HostAndPort swWebappHostPort; private HostAndPort swWebappHostPort;
@SuppressWarnings("unused")
@ContainerHostAndPort(name = "provider-entry", port = 9090)
private HostAndPort entryProvider;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ContainerHostAndPort(name = "nginx", port = 8080) @ContainerHostAndPort(name = "nginx", port = 8080)
private HostAndPort nginxHostPort; private HostAndPort nginxHostPort;
private final String nginxServiceName = "User_Service_Name"; private final String nginxServiceName = "User_Service_Name";
private final String entryServiceName = "e2e-service-entry-provider";
@BeforeAll @BeforeAll
public void setUp() throws Exception { public void setUp() throws Exception {
queryClient(swWebappHostPort); queryClient(swWebappHostPort);
trafficController(nginxHostPort, "/nginx/info"); trafficController(entryProvider, "/nginx/entry/info?backend=" + nginxHostPort.host() + ":" + nginxHostPort.port());
} }
@AfterAll @AfterAll
...@@ -144,8 +149,8 @@ public class LuaE2E extends SkyWalkingTestAdapter { ...@@ -144,8 +149,8 @@ public class LuaE2E extends SkyWalkingTestAdapter {
new ServiceInstanceTopologyQuery().stepByMinute() new ServiceInstanceTopologyQuery().stepByMinute()
.start(startTime.minusDays(1)) .start(startTime.minusDays(1))
.end(now()) .end(now())
.clientServiceId("1") .clientServiceId("ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1")
.serverServiceId("4")); .serverServiceId("VXNlcl9TZXJ2aWNlX05hbWU=.1"));
LOGGER.info("topology: {}", topology); LOGGER.info("topology: {}", topology);
...@@ -177,8 +182,10 @@ public class LuaE2E extends SkyWalkingTestAdapter { ...@@ -177,8 +182,10 @@ public class LuaE2E extends SkyWalkingTestAdapter {
if (nginxServiceName.equals(service.getLabel())) { if (nginxServiceName.equals(service.getLabel())) {
load("expected/lua/nginxEndpoints.yml").as(EndpointsMatcher.class).verify(endpoints); load("expected/lua/nginxEndpoints.yml").as(EndpointsMatcher.class).verify(endpoints);
} else if (entryServiceName.equals(service.getLabel())) {
load("expected/lua/endpoints-entry.yml").as(EndpointsMatcher.class).verify(endpoints);
} else { } else {
load("expected/lua/endpoints.yml").as(EndpointsMatcher.class).verify(endpoints); load("expected/lua/endpoints-end.yml").as(EndpointsMatcher.class).verify(endpoints);
} }
return endpoints; return endpoints;
...@@ -206,7 +213,7 @@ public class LuaE2E extends SkyWalkingTestAdapter { ...@@ -206,7 +213,7 @@ public class LuaE2E extends SkyWalkingTestAdapter {
private void verifyEndpointsMetrics(Endpoints endpoints) throws Exception { private void verifyEndpointsMetrics(Endpoints endpoints) throws Exception {
for (Endpoint endpoint : endpoints.getEndpoints()) { for (Endpoint endpoint : endpoints.getEndpoints()) {
if (!endpoint.getLabel().equals("/info") || !endpoint.getLabel().equals("/nginx/info")) { if (!endpoint.getLabel().equals("/info") && !endpoint.getLabel().equals("/nginx/info")) {
continue; continue;
} }
for (final String metricName : ALL_ENDPOINT_METRICS) { for (final String metricName : ALL_ENDPOINT_METRICS) {
......
# 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.
endpoints:
- key: not null
label: /nginx/entry/info
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
instances: instances:
- key: 2 - key: not null
label: not null label: not null
attributes: attributes:
- name: OS Name - name: OS Name
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
endpoints: endpoints:
- key: not null - key: VXNlcl9TZXJ2aWNlX05hbWU=.1_L25naW54L2luZm8=
label: /nginx/info label: /nginx/info
......
...@@ -14,5 +14,5 @@ ...@@ -14,5 +14,5 @@
# limitations under the License. # limitations under the License.
instances: instances:
- key: 4 - key: VXNlcl9TZXJ2aWNlX05hbWU=.1_VXNlcl9TZXJ2aWNlX0luc3RhbmNlX05hbWU=
label: not null label: User_Service_Instance_Name
...@@ -14,21 +14,22 @@ ...@@ -14,21 +14,22 @@
# limitations under the License. # limitations under the License.
nodes: nodes:
- id: 1 - id: VXNlcl9TZXJ2aWNlX05hbWU=.1_VXNlcl9TZXJ2aWNlX0luc3RhbmNlX05hbWU=
name: User name: User_Service_Instance_Name
type: USER
serviceId: 1
serviceName: User
isReal: false
- id: 4
name: not null
serviceId: 4
serviceName: User_Service_Name
type: not null type: not null
serviceId: VXNlcl9TZXJ2aWNlX05hbWU=.1
serviceName: User_Service_Name
isReal: true
- id: not null
name: not null
serviceId: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
serviceName: e2e-service-entry-provider
type: ""
isReal: true isReal: true
calls: calls:
- id: 1_4 - id: not null
source: 1 source: not null
detectPoints: detectPoints:
- CLIENT
- SERVER - SERVER
target: 4 target: VXNlcl9TZXJ2aWNlX05hbWU=.1_VXNlcl9TZXJ2aWNlX0luc3RhbmNlX05hbWU=
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
# limitations under the License. # limitations under the License.
services: services:
- key: gt 0 - key: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
label: "Your_ApplicationName" label: "e2e-service-entry-provider"
- key: gt 0 - key: VXNlcl9TZXJ2aWNlX05hbWU=.1
label: "User_Service_Name" label: "User_Service_Name"
\ No newline at end of file - key: ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1
label: "e2e-service-end-provider"
\ No newline at end of file
...@@ -14,41 +14,46 @@ ...@@ -14,41 +14,46 @@
# limitations under the License. # limitations under the License.
nodes: nodes:
- id: 1 - id: VXNlcg==.0
name: User name: User
type: USER type: USER
isReal: false isReal: false
- id: 2 - id: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
name: Your_ApplicationName name: e2e-service-entry-provider
type: Tomcat type: Tomcat
isReal: true isReal: true
- id: 3 - id: VXNlcl9TZXJ2aWNlX05hbWU=.1
name: localhost:-1
type: H2
isReal: false
- id: 4
name: User_Service_Name name: User_Service_Name
type: Nginx type: Nginx
isReal: true isReal: true
- id: ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1
name: e2e-service-end-provider
type: Tomcat
isReal: true
- id: bG9jYWxob3N0Oi0x.0
name: localhost:-1
type: H2
isReal: false
calls: calls:
- id: 1_4 - id: VXNlcg==.0-ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
source: 1 source: VXNlcg==.0
detectPoints: detectPoints:
- SERVER - SERVER
target: 4 target: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
- id: 4_2 - id: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1-VXNlcl9TZXJ2aWNlX05hbWU=.1
source: 4 source: ZTJlLXNlcnZpY2UtZW50cnktcHJvdmlkZXI=.1
detectPoints: detectPoints:
- CLIENT - CLIENT
- SERVER - SERVER
target: 2 target: VXNlcl9TZXJ2aWNlX05hbWU=.1
- id: 2_3 - id: VXNlcl9TZXJ2aWNlX05hbWU=.1-ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1
source: 2 source: VXNlcl9TZXJ2aWNlX05hbWU=.1
detectPoints: detectPoints:
- CLIENT - CLIENT
target: 3
- id: 1_2
source: 1
detectPoints:
- SERVER - SERVER
target: 2 target: ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1
\ No newline at end of file - id: ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1-bG9jYWxob3N0Oi0x.0
source: ZTJlLXNlcnZpY2UtZW5kLXByb3ZpZGVy.1
detectPoints:
- CLIENT
target: bG9jYWxob3N0Oi0x.0
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
traces: traces:
- key: not null - key: not null
endpointNames: endpointNames:
- /info - /nginx/entry/info
duration: ge 0 duration: ge 0
start: gt 0 start: gt 0
isError: false isError: false
...@@ -30,4 +30,13 @@ traces: ...@@ -30,4 +30,13 @@ traces:
start: gt 0 start: gt 0
isError: false isError: false
traceIds: traceIds:
- not null - not null
\ No newline at end of file
- key: not null
endpointNames:
- /info
duration: ge 0
start: gt 0
isError: false
traceIds:
- not null
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册