Skip to content

Commit c894122

Browse files
committed
✅ test: rabbitmq config 코드 삭제에 따라 test환경에서 definitions.json이 적용될 수 있도록 수정
1 parent 8e6541a commit c894122

File tree

2 files changed

+123
-1
lines changed

2 files changed

+123
-1
lines changed

server/test/definitions.json

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"vhosts": [
3+
{
4+
"name": "/"
5+
}
6+
],
7+
"permissions": [
8+
{
9+
"user": "guest",
10+
"vhost": "/",
11+
"configure": ".*",
12+
"write": ".*",
13+
"read": ".*"
14+
}
15+
],
16+
"exchanges": [
17+
{
18+
"name": "EmailExchange",
19+
"vhost": "/",
20+
"type": "direct",
21+
"durable": true,
22+
"auto_delete": false
23+
},
24+
{
25+
"name": "CrawlingExchange",
26+
"vhost": "/",
27+
"type": "topic",
28+
"durable": true,
29+
"auto_delete": false
30+
},
31+
{
32+
"name": "DeadLetterExchange",
33+
"vhost": "/",
34+
"type": "topic",
35+
"durable": true,
36+
"auto_delete": false
37+
}
38+
],
39+
"queues": [
40+
{
41+
"name": "email.send.queue",
42+
"vhost": "/",
43+
"durable": true,
44+
"auto_delete": false,
45+
"arguments": {
46+
"x-dead-letter-exchange": "DeadLetterExchange",
47+
"x-dead-letter-routing-key": "email.deadLetter"
48+
}
49+
},
50+
{
51+
"name": "crawling.full.queue",
52+
"vhost": "/",
53+
"durable": true,
54+
"auto_delete": false,
55+
"arguments": {
56+
"x-dead-letter-exchange": "DeadLetterExchange",
57+
"x-dead-letter-routing-key": "crawling.full.deadLetter"
58+
}
59+
},
60+
{
61+
"name": "email.deadLetter.queue",
62+
"vhost": "/",
63+
"durable": true,
64+
"auto_delete": false,
65+
"arguments": {}
66+
},
67+
{
68+
"name": "crawling.full.deadLetter.queue",
69+
"vhost": "/",
70+
"durable": true,
71+
"auto_delete": false,
72+
"arguments": {}
73+
}
74+
],
75+
"bindings": [
76+
{
77+
"source": "EmailExchange",
78+
"vhost": "/",
79+
"destination": "email.send.queue",
80+
"destination_type": "queue",
81+
"routing_key": "email.send",
82+
"arguments": {}
83+
},
84+
{
85+
"source": "CrawlingExchange",
86+
"vhost": "/",
87+
"destination": "crawling.full.queue",
88+
"destination_type": "queue",
89+
"routing_key": "crawling.full",
90+
"arguments": {}
91+
},
92+
{
93+
"source": "DeadLetterExchange",
94+
"vhost": "/",
95+
"destination": "email.deadLetter.queue",
96+
"destination_type": "queue",
97+
"routing_key": "email.deadLetter",
98+
"arguments": {}
99+
},
100+
{
101+
"source": "DeadLetterExchange",
102+
"vhost": "/",
103+
"destination": "crawling.full.deadLetter.queue",
104+
"destination_type": "queue",
105+
"routing_key": "crawling.full.deadLetter",
106+
"arguments": {}
107+
}
108+
]
109+
}

server/test/integration-test-global-setup.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
RabbitMQContainer,
55
StartedRabbitMQContainer,
66
} from '@testcontainers/rabbitmq';
7+
import * as path from 'path';
78

89
const globalAny: any = global;
910

@@ -49,13 +50,25 @@ const createRedisContainer = async () => {
4950
const createRabbitMQContainer = async () => {
5051
console.log('Starting RabbitMQ container...');
5152
const rabbitMQContainer: StartedRabbitMQContainer =
52-
await new RabbitMQContainer('rabbitmq:4.1-management').start();
53+
await new RabbitMQContainer('rabbitmq:4.1-management')
54+
.withCopyFilesToContainer([
55+
{
56+
source: `${path.resolve(__dirname, 'definitions.json')}`,
57+
target: '/etc/rabbitmq/definitions.json',
58+
},
59+
])
60+
.start();
5361
globalAny.__RABBITMQ_CONTAINER__ = rabbitMQContainer;
5462

5563
process.env.RABBITMQ_HOST = rabbitMQContainer.getHost();
5664
process.env.RABBITMQ_PORT = rabbitMQContainer.getMappedPort(5672).toString();
5765
process.env.RABBITMQ_DEFAULT_USER = 'guest';
5866
process.env.RABBITMQ_DEFAULT_PASS = 'guest';
67+
const result = await rabbitMQContainer.exec([
68+
'rabbitmqctl',
69+
'import_definitions',
70+
'/etc/rabbitmq/definitions.json',
71+
]);
5972
};
6073

6174
const jwtEnvSetup = () => {

0 commit comments

Comments
 (0)