Skip to content

Commit b1c82b4

Browse files
Merge pull request #12730 from rabbitmq/test-amqp10-session-link-details-in-ui
Test amqp10 session and link information in management ui
2 parents 047cc5a + a8e7d69 commit b1c82b4

File tree

14 files changed

+298
-35
lines changed

14 files changed

+298
-35
lines changed

deps/rabbitmq_management/priv/www/js/tmpl/connection.ejs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h2>Connection <%= fmt_string(connection.name) %> <%= fmt_maybe_vhost(connection.vhost) %></h1>
22

33
<% if (!disable_stats) { %>
4-
<div class="section">
4+
<div class="section" id="connection-overview-section">
55
<h2>Overview</h2>
66
<div class="hider updatable">
77
<%= data_rates('data-rates-conn', connection, 'Data rates') %>
@@ -86,7 +86,7 @@
8686
8787
<% if (connection.protocol === 'AMQP 1-0') { %>
8888
89-
<div class="section">
89+
<div class="section" id="connection-sessions-section">
9090
<h2 class="updatable" >Sessions (<%=(sessions.length)%>)</h2>
9191
<div class="hider updatable">
9292
<%= format('sessions-list', {'sessions': sessions}) %>
@@ -95,7 +95,7 @@
9595
9696
<% } else { %>
9797
98-
<div class="section">
98+
<div class="section" id="connection-channels-section">
9999
<h2 class="updatable" >Channels (<%=(channels.length)%>) </h2>
100100
<div class="hider updatable">
101101
<%= format('channels-list', {'channels': channels, 'mode': 'connection'}) %>
@@ -149,7 +149,7 @@
149149
<% } %>
150150
151151
<% if (properties_size(connection.client_properties) > 0) { %>
152-
<div class="section-hidden">
152+
<div class="section-hidden" id="connection-client-properies-section">
153153
<h2>Client properties</h2>
154154
<div class="hider">
155155
<%= fmt_table_long(connection.client_properties) %>
@@ -158,7 +158,7 @@
158158
<% } %>
159159
160160
<% if(connection.reductions || connection.garbage_collection) { %>
161-
<div class="section-hidden">
161+
<div class="section-hidden" id="connection-runtime-metrics-section">
162162
<h2>Runtime Metrics (Advanced)</h2>
163163
<div class="hider updatable">
164164
<%= data_reductions('reductions-rates-conn', connection) %>
@@ -197,7 +197,7 @@
197197
<% } %>
198198
<% } %>
199199

200-
<div class="section-hidden">
200+
<div class="section-hidden" id="connection-close-section">
201201
<h2>Close this connection</h2>
202202
<div class="hider">
203203
<form action="#/connections" method="delete" class="confirm">

deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Connections</h1>
2-
<div class="section">
2+
<div class="section" id="connections-paging-section">
33
<%= paginate_ui(connections, 'connections') %>
44
</div>
5-
<div class="updatable">
5+
<div class="updatable" id="connections-table-section">
66
<% if (connections.items.length > 0) { %>
77
<table class="list">
88
<thead>

deps/rabbitmq_management/priv/www/js/tmpl/sessions-list.ejs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<% if (sessions.length > 0) { %>
2-
<table class="list">
2+
<table class="list" id="sessions">
33
<thead>
44
<tr>
55
<th>Channel number</th>
@@ -18,7 +18,7 @@
1818
for (var i = 0; i < sessions.length; i++) {
1919
var session = sessions[i];
2020
%>
21-
<tr>
21+
<tr class="session">
2222
<td class="c"><%= fmt_string(session.channel_number) %></td>
2323
<td class="c"><%= fmt_string(session.handle_max) %></td>
2424
<td class="c"><%= fmt_string(session.next_incoming_id) %></td>
@@ -30,9 +30,9 @@
3030
</tr>
3131
<% if (session.incoming_links.length > 0) { %>
3232
<tr>
33-
<td colspan="8">
33+
<td colspan="8" >
3434
<p>Incoming Links (<%=(session.incoming_links.length)%>) <span class="help" id="incoming-links"></span></p>
35-
<table class="list">
35+
<table class="list" id="incoming-links">
3636
<thead>
3737
<tr>
3838
<th>Link handle</th>
@@ -50,7 +50,7 @@
5050
for (var j = 0; j < session.incoming_links.length; j++) {
5151
var in_link = session.incoming_links[j];
5252
%>
53-
<tr>
53+
<tr class="link">
5454
<td class="c"><%= fmt_string(in_link.handle) %></td>
5555
<td class="c"><%= fmt_string(in_link.link_name) %></td>
5656
<td class="c"><%= fmt_string(in_link.target_address) %></td>
@@ -68,9 +68,9 @@
6868
<% } %>
6969
<% if (session.outgoing_links.length > 0) { %>
7070
<tr>
71-
<td colspan="8">
71+
<td colspan="8" >
7272
<p>Outgoing Links (<%=(session.outgoing_links.length)%>) <span class="help" id="outgoing-links"></span></p>
73-
<table class="list">
73+
<table class="list" id="outgoing-links">
7474
<thead>
7575
<tr>
7676
<th>Link handle</th>
@@ -88,7 +88,7 @@
8888
for (var k = 0; k < session.outgoing_links.length; k++) {
8989
var out_link = session.outgoing_links[k];
9090
%>
91-
<tr>
91+
<tr class="link">
9292
<td class="c"><%= fmt_string(out_link.handle) %></td>
9393
<td class="c"><%= fmt_string(out_link.link_name) %></td>
9494
<td class="c"><%= fmt_string(out_link.source_address) %></td>

selenium/amqp10-roundtriptest/src/main/java/com/rabbitmq/amqp1_0/RoundTripTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public static void main(String args[]) throws Exception {
3030
String username = args.length > 0 ? args[0] : getEnv("RABBITMQ_AMQP_USERNAME", "guest");
3131
String password = args.length > 1 ? args[1] : getEnv("RABBITMQ_AMQP_PASSWORD", "guest");
3232

33-
boolean usemtls = Boolean.parseBoolean(getEnv("AMQP_USE_MTLS", "false"));
34-
String certsLocation = getEnv("RABBITMQ_CERTS");
33+
boolean usemtls = Boolean.parseBoolean(getEnv("AMQP_USE_MTLS", "false"));
3534

3635
if ("amqps".equals(scheme)) {
3736
List<String> connectionParams = new ArrayList<String>();
37+
String certsLocation = getEnv("RABBITMQ_CERTS");
3838

3939
connectionParams.add("transport.trustStoreLocation=" + certsLocation + "/truststore.jks");
4040
connectionParams.add("transport.trustStorePassword=foobar");
@@ -84,6 +84,8 @@ public static void main(String args[]) throws Exception {
8484
TextMessage receivedMessage = (TextMessage) messageConsumer.receive(2000L);
8585

8686
assertEquals(message.getText(), receivedMessage.getText());
87+
88+
Thread.sleep(60000);
8789
}
8890
}
8991
private static Connection createConnection(ConnectionFactory factory,

selenium/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
"author": "",
1414
"license": "ISC",
1515
"dependencies": {
16-
"chromedriver": "^128.0.0",
16+
"chromedriver": "^130.0.4",
1717
"ejs": "^3.1.8",
1818
"express": "^4.18.2",
1919
"geckodriver": "^3.0.2",
2020
"http-proxy": "^1.18.1",
2121
"mqtt": "^5.3.3",
2222
"path": "^0.12.7",
2323
"proxy": "^1.0.2",
24-
"selenium-webdriver": "^4.19.0",
24+
"rhea": "^3.0.3",
25+
"selenium-webdriver": "^4.26.0",
2526
"xmlhttprequest": "^1.8.0"
2627
},
2728
"devDependencies": {

selenium/short-suite-management-ui

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ authnz-mgt/oauth-with-uaa.sh
44
mgt/vhosts.sh
55
mgt/exchanges.sh
66
mgt/limits.sh
7+
mgt/amqp10-connections.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
TEST_CASES_PATH=/connections/amqp10
6+
TEST_CONFIG_PATH=/basic-auth
7+
8+
source $SCRIPT/../../bin/suite_template $@
9+
run

selenium/test/basic-auth/imports/users.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
"vhosts": [
5757
{
5858
"name": "/"
59+
},
60+
{
61+
"name": "other"
5962
}
6063
],
6164
"permissions": [
@@ -79,6 +82,20 @@
7982
"configure": ".*",
8083
"write": ".*",
8184
"read": ".*"
85+
},
86+
{
87+
"user": "rabbit_no_management",
88+
"vhost": "other",
89+
"configure": ".*",
90+
"write": ".*",
91+
"read": ".*"
92+
},
93+
{
94+
"user": "monitoring-only",
95+
"vhost": "other",
96+
"configure": ".*",
97+
"write": ".*",
98+
"read": ".*"
8299
}
83100
]
84101

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
const { By, Key, until, Builder } = require('selenium-webdriver')
2+
require('chromedriver')
3+
const assert = require('assert')
4+
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../../utils')
5+
6+
const LoginPage = require('../../pageobjects/LoginPage')
7+
const OverviewPage = require('../../pageobjects/OverviewPage')
8+
const ConnectionsPage = require('../../pageobjects/ConnectionsPage')
9+
const ConnectionPage = require('../../pageobjects/ConnectionPage')
10+
11+
var container = require('rhea') // https://github.com/amqp/rhea
12+
var receivedAmqpMessageCount = 0
13+
var untilConnectionEstablished = new Promise((resolve, reject) => {
14+
container.on('connection_open', function(context) {
15+
resolve()
16+
})
17+
})
18+
19+
container.on('message', function (context) {
20+
receivedAmqpMessageCount++
21+
})
22+
container.once('sendable', function (context) {
23+
context.sender.send({body:'first message'})
24+
})
25+
26+
27+
describe('Given an amqp10 connection opened, listed and clicked on it', function () {
28+
let captureScreen
29+
let connectionsPage
30+
let connectionPage
31+
let connection
32+
33+
before(async function () {
34+
driver = buildDriver()
35+
await goToHome(driver)
36+
login = new LoginPage(driver)
37+
overview = new OverviewPage(driver)
38+
connectionsPage = new ConnectionsPage(driver)
39+
connectionPage = new ConnectionPage(driver)
40+
captureScreen = captureScreensFor(driver, __filename)
41+
await login.login('monitoring-only', 'guest')
42+
await overview.isLoaded()
43+
44+
connection = container.connect(
45+
{'host': process.env.RABBITMQ_HOSTNAME || 'rabbitmq',
46+
'port': process.env.RABBITMQ_AMQP_PORT || 5672,
47+
'username' : process.env.RABBITMQ_AMQP_USERNAME || 'guest',
48+
'password' : process.env.RABBITMQ_AMQP_PASSWORD || 'guest',
49+
'id': "selenium-connection-id",
50+
'container_id': "selenium-container-id"
51+
})
52+
connection.open_receiver({
53+
source: 'examples',
54+
target: 'receiver-target',
55+
name: 'receiver-link'
56+
})
57+
sender = connection.open_sender({
58+
target: 'examples',
59+
source: 'sender-source',
60+
name: 'sender-link'
61+
})
62+
await untilConnectionEstablished
63+
await overview.clickOnConnectionsTab()
64+
await connectionsPage.isLoaded()
65+
66+
connections_table = await connectionsPage.getConnectionsTable(20)
67+
assert.equal(1, connections_table.length)
68+
await connectionsPage.clickOnConnection(2)
69+
await connectionPage.isLoaded()
70+
})
71+
72+
73+
it('can list session information', async function () {
74+
let sessions = await connectionPage.getSessions()
75+
assert.equal(1, sessions.sessions.length)
76+
let session = connectionPage.getSessionInfo(sessions.sessions, 0)
77+
//console.log("session: " + JSON.stringify(session))
78+
assert.equal(0, session.channelNumber)
79+
assert.equal(1, session.nextIncomingId)
80+
assert.equal(0, session.outgoingUnsettledDeliveries)
81+
})
82+
83+
it('can list link information', async function () {
84+
let sessions = await connectionPage.getSessions()
85+
assert.equal(1, sessions.incoming_links.length)
86+
assert.equal(1, sessions.outgoing_links.length)
87+
88+
let incomingLink = connectionPage.getIncomingLinkInfo(sessions.incoming_links, 0)
89+
//console.log("incomingLink: " + JSON.stringify(incomingLink))
90+
assert.equal(1, incomingLink.handle)
91+
assert.equal("sender-link", incomingLink.name)
92+
assert.equal("examples", incomingLink.targetAddress)
93+
assert.equal("mixed", incomingLink.sndSettleMode)
94+
assert.equal("0", incomingLink.unconfirmedMessages)
95+
assert.equal(1, incomingLink.deliveryCount)
96+
97+
let outgoingLink = connectionPage.getOutgoingLinkInfo(sessions.outgoing_links, 0)
98+
//console.log("outgoingLink: " + JSON.stringify(outgoingLink))
99+
assert.equal(0, outgoingLink.handle)
100+
assert.equal("receiver-link", outgoingLink.name)
101+
assert.equal("examples", outgoingLink.sourceAddress)
102+
assert.equal("examples", outgoingLink.queueName)
103+
104+
assert.equal(false, outgoingLink.sendSettled)
105+
assert.equal("unlimited", outgoingLink.maxMessageSize)
106+
107+
})
108+
109+
it('display live link information', async function () {
110+
var untilMessageReceived = new Promise((resolve, reject) => {
111+
container.on('message', function(context) {
112+
resolve()
113+
})
114+
})
115+
sender.send({body:'second message'})
116+
await untilMessageReceived
117+
assert.equal(2, receivedAmqpMessageCount)
118+
119+
await delay(5*1000) // wait until page refreshes
120+
let sessions = await connectionPage.getSessions()
121+
let incomingLink = connectionPage.getIncomingLinkInfo(sessions.incoming_links, 0)
122+
assert.equal(2, incomingLink.deliveryCount)
123+
124+
//console.log("incomingLink: " + JSON.stringify(incomingLink))
125+
//console.log("outgoingLink: " + JSON.stringify(outgoingLink))
126+
})
127+
128+
129+
after(async function () {
130+
await teardown(driver, this, captureScreen)
131+
try {
132+
if (connection != null) {
133+
connection.close()
134+
}
135+
} catch (error) {
136+
console.error("Failed to close amqp10 connection due to " + error);
137+
}
138+
})
139+
140+
})

selenium/test/exchanges/management.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,31 @@ describe('Exchange management', function () {
3232
})
3333

3434
it('display summary of exchanges', async function () {
35-
assert.equal("All exchanges (8)", await exchanges.getPagingSectionHeaderText())
35+
assert.equal("All exchanges (15)", await exchanges.getPagingSectionHeaderText())
3636
})
3737

3838
it('list all default exchanges', async function () {
39-
actual_table = await exchanges.getExchangesTable(3)
40-
console.log("a :" + actual_table)
41-
expected_table = [
39+
let actual_table = await exchanges.getExchangesTable(3)
40+
41+
let expected_table = [
4242
["/", "(AMQP default)", "direct"],
4343
["/", "amq.direct", "direct"],
4444
["/", "amq.fanout", "fanout"],
4545
["/", "amq.headers", "headers"],
4646
["/", "amq.match", "headers"],
4747
["/", "amq.rabbitmq.event", "topic"],
4848
["/", "amq.rabbitmq.trace", "topic"],
49-
["/", "amq.topic", "topic"]
49+
["/", "amq.topic", "topic"],
50+
51+
["other", "(AMQP default)", "direct"],
52+
["other", "amq.direct", "direct"],
53+
["other", "amq.fanout", "fanout"],
54+
["other", "amq.headers", "headers"],
55+
["other", "amq.match", "headers"],
56+
["other", "amq.rabbitmq.trace", "topic"],
57+
["other", "amq.topic", "topic"]
5058
]
59+
5160
console.log("e :" + actual_table)
5261
assert.deepEqual(actual_table, expected_table)
5362
})

0 commit comments

Comments
 (0)