Skip to content

Commit 802483e

Browse files
Deprecate java amqp1.0 client
from ui and messaging selenium tests
1 parent 171bb1c commit 802483e

File tree

3 files changed

+70
-68
lines changed

3 files changed

+70
-68
lines changed

selenium/test/amqp.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,49 @@ function getAmqpsConnectionOptions() {
2424
options['cert'] = fs.readFileSync(path.resolve(certsLocation,'client_rabbitmq_certificate.pem'))
2525
options['ca'] = fs.readFileSync(path.resolve(certsLocation,'ca_rabbitmq_certificate.pem'))
2626
}
27-
module.exports = {
27+
function getConnectionOptions() {
28+
switch(process.env.RABBITMQ_AMQP_SCHEME || 'amqp'){
29+
case 'amqp':
30+
return getAmqpConnectionOptions()
31+
case 'amqps':
32+
return getAmqpsConnectionOptions()
33+
}
34+
}
35+
module.exports = {
36+
2837
open: () => {
29-
switch(process.env.RABBITMQ_AMQP_SCHEME || 'amqp'){
30-
case 'amqp':
31-
return container.connect(getAmqpConnectionOptions())
32-
case 'amqps':
33-
return container.connect(getAmqpsConnectionOptions())
34-
}
38+
let promise = new Promise((resolve, reject) => {
39+
container.on('connection_open', function(context) {
40+
resolve()
41+
})
42+
})
43+
let connection = container.connect(getConnectionOptions())
44+
let receiver = connection.open_receiver({
45+
source: 'examples',
46+
target: 'receiver-target',
47+
name: 'receiver-link'
48+
})
49+
let sender = connection.open_sender({
50+
target: 'examples',
51+
source: 'sender-source',
52+
name: 'sender-link'
53+
})
54+
return {
55+
'connection': connection,
56+
'promise' : promise,
57+
'receiver' : receiver,
58+
'sender' : sender
59+
}
60+
},
61+
close: (connection) => {
62+
if (connection != null) {
63+
connection.close()
64+
}
65+
},
66+
once: (event, callback) => {
67+
container.once(event, callback)
68+
},
69+
on: (event, callback) => {
70+
container.on(event, callback)
3571
}
3672
}
Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
const assert = require('assert')
22
const { tokenFor, openIdConfiguration } = require('../utils')
33
const { reset, expectUser, expectVhost, expectResource, allow, verifyAll } = require('../mock_http_backend')
4+
const { open: openAmqp, once: onceAmqp, on: onAmqp, close: closeAmqp } = require('../amqp')
45
const {execSync} = require('child_process')
56

6-
var container = require('rhea') // https://github.com/amqp/rhea
77
var receivedAmqpMessageCount = 0
88
var untilConnectionEstablished = new Promise((resolve, reject) => {
9-
container.on('connection_open', function(context) {
9+
onAmqp('connection_open', function(context) {
1010
resolve()
1111
})
1212
})
1313

14-
container.on('message', function (context) {
14+
onAmqp('message', function (context) {
1515
receivedAmqpMessageCount++
1616
})
17-
container.once('sendable', function (context) {
17+
onceAmqp('sendable', function (context) {
1818
context.sender.send({body:'first message'})
1919
})
2020

@@ -33,7 +33,8 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
3333
let usemtls = process.env.AMQP_USE_MTLS
3434
let amqpClientCommand = "npm run amqp10_roundtriptest" +
3535
(usemtls ? "" : " " + username + " " + password)
36-
36+
let amqp;
37+
3738
before(function () {
3839
if (backends.includes("http") && username.includes("http")) {
3940
reset()
@@ -55,43 +56,28 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
5556
})
5657

5758
it('can open an AMQP 1.0 connection', async function () {
58-
connection = container.connect(
59-
{'host': process.env.RABBITMQ_HOSTNAME || 'rabbitmq',
60-
'port': process.env.RABBITMQ_AMQP_PORT || 5672,
61-
'username' : process.env.RABBITMQ_AMQP_USERNAME || 'guest',
62-
'password' : process.env.RABBITMQ_AMQP_PASSWORD || 'guest',
63-
'id': "selenium-connection-id",
64-
'container_id': "selenium-container-id",
65-
'scheme': process.env.RABBITMQ_AMQP_SCHEME || 'amqp',
66-
//enable_sasl_external:true,
67-
68-
})
69-
connection.open_receiver({
70-
source: 'examples',
71-
target: 'receiver-target',
72-
name: 'receiver-link'
73-
})
74-
sender = connection.open_sender({
75-
target: 'examples',
76-
source: 'sender-source',
77-
name: 'sender-link'
78-
})
59+
amqp = openAmqp()
7960
await untilConnectionEstablished
8061
var untilMessageReceived = new Promise((resolve, reject) => {
81-
container.on('message', function(context) {
62+
onAmqp('message', function(context) {
8263
resolve()
8364
})
8465
})
85-
sender.send({body:'second message'})
66+
amqp.sender.send({body:'second message'})
8667
await untilMessageReceived
8768
assert.equal(2, receivedAmqpMessageCount)
8869

8970
//console.log(execSync(amqpClientCommand).toString())
9071
})
9172

9273
after(function () {
93-
if ( backends.includes("http") ) {
94-
verifyAll(expectations)
95-
}
74+
if ( backends.includes("http") ) {
75+
verifyAll(expectations)
76+
}
77+
try {
78+
closeAmqp(amqp.connection)
79+
} catch (error) {
80+
console.error("Failed to close amqp10 connection due to " + error);
81+
}
9682
})
9783
})

selenium/test/connections/amqp10/sessions-for-monitoring-user.js

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
const { By, Key, until, Builder } = require('selenium-webdriver')
22
require('chromedriver')
33
const assert = require('assert')
4+
const { open: openAmqp, once: onceAmqp, on: onAmqp, close: closeAmqp } = require('../../amqp')
45
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require('../../utils')
56

67
const LoginPage = require('../../pageobjects/LoginPage')
78
const OverviewPage = require('../../pageobjects/OverviewPage')
89
const ConnectionsPage = require('../../pageobjects/ConnectionsPage')
910
const ConnectionPage = require('../../pageobjects/ConnectionPage')
1011

11-
var container = require('rhea') // https://github.com/amqp/rhea
1212
var receivedAmqpMessageCount = 0
1313
var untilConnectionEstablished = new Promise((resolve, reject) => {
14-
container.on('connection_open', function(context) {
14+
onAmqp('connection_open', function(context) {
1515
resolve()
1616
})
1717
})
1818

19-
container.on('message', function (context) {
19+
onAmqp('message', function (context) {
2020
receivedAmqpMessageCount++
2121
})
22-
container.once('sendable', function (context) {
22+
onceAmqp('sendable', function (context) {
2323
context.sender.send({body:'first message'})
2424
})
2525

@@ -28,7 +28,7 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
2828
let captureScreen
2929
let connectionsPage
3030
let connectionPage
31-
let connection
31+
let amqp
3232

3333
before(async function () {
3434
driver = buildDriver()
@@ -41,24 +41,8 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
4141
await login.login('monitoring-only', 'guest')
4242
await overview.isLoaded()
4343

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-
})
44+
45+
amqp = openAmqp()
6246
await untilConnectionEstablished
6347
await overview.clickOnConnectionsTab()
6448
await connectionsPage.isLoaded()
@@ -108,11 +92,11 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
10892

10993
it('display live link information', async function () {
11094
var untilMessageReceived = new Promise((resolve, reject) => {
111-
container.on('message', function(context) {
95+
onAmqp('message', function(context) {
11296
resolve()
11397
})
11498
})
115-
sender.send({body:'second message'})
99+
amqp.sender.send({body:'second message'})
116100
await untilMessageReceived
117101
assert.equal(2, receivedAmqpMessageCount)
118102

@@ -121,17 +105,13 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
121105
let incomingLink = connectionPage.getIncomingLinkInfo(sessions.incoming_links, 0)
122106
assert.equal(2, incomingLink.deliveryCount)
123107

124-
//console.log("incomingLink: " + JSON.stringify(incomingLink))
125-
//console.log("outgoingLink: " + JSON.stringify(outgoingLink))
126108
})
127109

128110

129111
after(async function () {
130112
await teardown(driver, this, captureScreen)
131113
try {
132-
if (connection != null) {
133-
connection.close()
134-
}
114+
closeAmqp(amqp.connection)
135115
} catch (error) {
136116
console.error("Failed to close amqp10 connection due to " + error);
137117
}

0 commit comments

Comments
 (0)