Skip to content

Commit 663704c

Browse files
committed
Update spring rabbitmq test
1 parent 23df581 commit 663704c

File tree

14 files changed

+122
-154
lines changed

14 files changed

+122
-154
lines changed

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/bin/startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
home="$(cd "$(dirname $0)"; pwd)"
1919

20-
java -Dspring.rabbitmq.host=${RABBITMQ_HOST} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-2.x-scenario.jar &
20+
java -Dspring.rabbitmq.host=${RABBITMQ_HOST:-rabbitmq-server} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-2.x-scenario.jar &

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/config/expectedData.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# distributed with this work for additional information
44
# regarding copyright ownership. The ASF licenses this file
55
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
6+
# "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
88
#
99
# http://www.apache.org/licenses/LICENSE-2.0
1010
#
@@ -19,28 +19,21 @@ segmentItems:
1919
segments:
2020
- segmentId: not null
2121
spans:
22-
- operationName: RabbitMQ/Topic/Queue/test/Consumer
22+
- operationName: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq
2323
parentSpanId: -1
2424
spanId: 0
25-
spanLayer: MQ
25+
spanLayer: Http
2626
startTime: nq 0
2727
endTime: nq 0
28-
componentId: 53
28+
componentId: 1
2929
isError: false
3030
spanType: Entry
31-
peer: not blank
31+
peer: ''
3232
tags:
33-
- {key: mq.broker, value: not blank}
34-
- {key: mq.topic, value: ''}
35-
- {key: mq.queue, value: test}
36-
- {key: transmission.latency, value: ge 0}
37-
refs:
38-
- {parentEndpoint: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq, networkAddress: not null,
39-
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
40-
null, parentService: spring-rabbitmq-2.x-scenario, traceId: not null}
33+
- {key: url, value: 'http://localhost:8080/spring-rabbitmq-2.x-scenario/case/rabbitmq'}
34+
- {key: http.method, value: GET}
35+
- {key: http.status_code, value: '200'}
4136
skipAnalysis: 'false'
42-
- segmentId: not null
43-
spans:
4437
- operationName: RabbitMQ/Topic/Queue/test/Producer
4538
parentSpanId: 0
4639
spanId: 1
@@ -56,18 +49,25 @@ segmentItems:
5649
- {key: mq.queue, value: test}
5750
- {key: mq.topic, value: ''}
5851
skipAnalysis: 'false'
59-
- operationName: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq
52+
- segmentId: not null
53+
spans:
54+
- operationName: RabbitMQ/Topic/Queue/test/Consumer
6055
parentSpanId: -1
6156
spanId: 0
62-
spanLayer: Http
57+
spanLayer: MQ
6358
startTime: nq 0
6459
endTime: nq 0
65-
componentId: 1
60+
componentId: 53
6661
isError: false
6762
spanType: Entry
68-
peer: ''
63+
peer: not blank
6964
tags:
70-
- {key: url, value: 'http://localhost:8080/spring-rabbitmq-2.x-scenario/case/rabbitmq'}
71-
- {key: http.method, value: GET}
72-
- {key: http.status_code, value: '200'}
65+
- {key: transmission.latency, value: ge 0}
66+
- {key: mq.broker, value: not blank}
67+
- {key: mq.topic, value: ''}
68+
- {key: mq.queue, value: test}
69+
refs:
70+
- {parentEndpoint: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq, networkAddress: not null,
71+
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
72+
null, parentService: spring-rabbitmq-2.x-scenario, traceId: not null}
7373
skipAnalysis: 'false'

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/configuration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ healthCheck: http://localhost:8080/spring-rabbitmq-2.x-scenario/case/healthcheck
1818
startScript: ./bin/startup.sh
1919
environment:
2020
- RABBITMQ_HOST=rabbitmq-server
21+
depends_on:
22+
- rabbitmq-server
2123
dependencies:
2224
rabbitmq-server:
2325
image: rabbitmq:3.8.18

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<plugin>
7676
<groupId>org.springframework.boot</groupId>
7777
<artifactId>spring-boot-maven-plugin</artifactId>
78-
<version>1.5.9.RELEASE</version>
78+
<version>${test.framework.version}</version>
7979
<executions>
8080
<execution>
8181
<goals>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.testcase.spring.rabbitmq.config;
20+
21+
import org.springframework.amqp.core.Queue;
22+
import org.springframework.context.annotation.Bean;
23+
import org.springframework.context.annotation.Configuration;
24+
25+
@Configuration
26+
public class RabbitMqConfig {
27+
28+
@Bean
29+
public Queue testQueue() {
30+
return new Queue("test", false);
31+
}
32+
}

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,16 @@
2323
import org.springframework.amqp.rabbit.annotation.RabbitListener;
2424
import org.springframework.amqp.rabbit.core.RabbitTemplate;
2525
import org.springframework.beans.factory.annotation.Autowired;
26-
import org.springframework.beans.factory.annotation.Value;
27-
import org.springframework.context.annotation.PropertySource;
2826
import org.springframework.web.bind.annotation.RequestMapping;
2927
import org.springframework.web.bind.annotation.ResponseBody;
3028
import org.springframework.web.bind.annotation.RestController;
3129

32-
import com.rabbitmq.client.Channel;
33-
import com.rabbitmq.client.Connection;
34-
import com.rabbitmq.client.ConnectionFactory;
35-
3630
@RestController
3731
@RequestMapping("/case")
38-
@PropertySource("classpath:application.yml")
3932
public class CaseController {
4033

4134
private static final Logger LOGGER = LogManager.getLogger(CaseController.class);
4235

43-
private static final String USERNAME = "admin";
44-
45-
private static final String PASSWORD = "admin";
46-
47-
@Value(value = "${spring.rabbitmq.host:127.0.0.1}")
48-
private String brokerUrl;
49-
50-
private static final int PORT = 5672;
51-
5236
private static final String QUEUE_NAME = "test";
5337

5438
private static final String MESSAGE = "rabbitmq-testcase";
@@ -72,41 +56,6 @@ public void consumer(String message) {
7256

7357
@RequestMapping("/healthcheck")
7458
public String healthCheck() throws Exception {
75-
Channel channel = null;
76-
Connection connection = null;
77-
78-
try {
79-
ConnectionFactory factory = new ConnectionFactory();
80-
LOGGER.info("Using brokerUrl = " + brokerUrl);
81-
factory.setHost(brokerUrl);
82-
factory.setPort(PORT);
83-
factory.setUsername(USERNAME);
84-
factory.setPassword(PASSWORD);
85-
86-
connection = factory.newConnection();
87-
88-
channel = connection.createChannel();
89-
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
90-
LOGGER.info("Completed Health Check. Able to connect to RabbitMQ and create queue-------------->");
91-
} catch (Exception ex) {
92-
LOGGER.error(ex.toString());
93-
throw ex;
94-
} finally {
95-
if (channel != null) {
96-
try {
97-
channel.close();
98-
} catch (Exception e) {
99-
// ignore
100-
}
101-
}
102-
if (connection != null) {
103-
try {
104-
connection.close();
105-
} catch (Exception e) {
106-
// ignore
107-
}
108-
}
109-
}
11059
return "Success";
11160
}
11261
}

test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/application.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ server:
2222

2323
spring:
2424
rabbitmq:
25-
host: 127.0.0.1
25+
host: ${RABBITMQ_HOST:127.0.0.1}
2626
port: 5672
2727
username: admin
2828
password: admin
29+
virtual-host: /

test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/bin/startup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
home="$(cd "$(dirname $0)"; pwd)"
1919

20-
java -Dspring.rabbitmq.host=${RABBITMQ_HOST} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-3.x-4.x-scenario.jar &
20+
java -Dspring.rabbitmq.host=${RABBITMQ_HOST:-rabbitmq-server} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-3.x-4.x-scenario.jar &

test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/config/expectedData.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# distributed with this work for additional information
44
# regarding copyright ownership. The ASF licenses this file
55
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
6+
# "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
88
#
99
# http://www.apache.org/licenses/LICENSE-2.0
1010
#
@@ -19,28 +19,21 @@ segmentItems:
1919
segments:
2020
- segmentId: not null
2121
spans:
22-
- operationName: RabbitMQ/Topic/Queue/test/Consumer
22+
- operationName: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq
2323
parentSpanId: -1
2424
spanId: 0
25-
spanLayer: MQ
25+
spanLayer: Http
2626
startTime: nq 0
2727
endTime: nq 0
28-
componentId: 53
28+
componentId: 1
2929
isError: false
3030
spanType: Entry
31-
peer: not blank
31+
peer: ''
3232
tags:
33-
- {key: mq.broker, value: not blank}
34-
- {key: mq.topic, value: ''}
35-
- {key: mq.queue, value: test}
36-
- {key: transmission.latency, value: ge 0}
37-
refs:
38-
- {parentEndpoint: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq, networkAddress: not null,
39-
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
40-
null, parentService: spring-rabbitmq-3.x-4.x-scenario, traceId: not null}
33+
- {key: url, value: 'http://localhost:8080/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq'}
34+
- {key: http.method, value: GET}
35+
- {key: http.status_code, value: '200'}
4136
skipAnalysis: 'false'
42-
- segmentId: not null
43-
spans:
4437
- operationName: RabbitMQ/Topic/Queue/test/Producer
4538
parentSpanId: 0
4639
spanId: 1
@@ -56,18 +49,25 @@ segmentItems:
5649
- {key: mq.queue, value: test}
5750
- {key: mq.topic, value: ''}
5851
skipAnalysis: 'false'
59-
- operationName: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq
52+
- segmentId: not null
53+
spans:
54+
- operationName: RabbitMQ/Topic/Queue/test/Consumer
6055
parentSpanId: -1
6156
spanId: 0
62-
spanLayer: Http
57+
spanLayer: MQ
6358
startTime: nq 0
6459
endTime: nq 0
65-
componentId: 1
60+
componentId: 53
6661
isError: false
6762
spanType: Entry
68-
peer: ''
63+
peer: not blank
6964
tags:
70-
- {key: url, value: 'http://localhost:8080/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq'}
71-
- {key: http.method, value: GET}
72-
- {key: http.status_code, value: '200'}
65+
- {key: transmission.latency, value: ge 0}
66+
- {key: mq.broker, value: not blank}
67+
- {key: mq.topic, value: ''}
68+
- {key: mq.queue, value: test}
69+
refs:
70+
- {parentEndpoint: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq, networkAddress: not null,
71+
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
72+
null, parentService: spring-rabbitmq-3.x-4.x-scenario, traceId: not null}
7373
skipAnalysis: 'false'

test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/configuration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ healthCheck: http://localhost:8080/spring-rabbitmq-3.x-4.x-scenario/case/healthc
1818
startScript: ./bin/startup.sh
1919
environment:
2020
- RABBITMQ_HOST=rabbitmq-server
21+
depends_on:
22+
- rabbitmq-server
2123
dependencies:
2224
rabbitmq-server:
2325
image: rabbitmq:3.8.18

0 commit comments

Comments
 (0)