Skip to content

Commit 9859ac8

Browse files
committed
v7.0.0 - Rename AGC to SCC
1 parent a80b25b commit 9859ac8

14 files changed

+332
-309
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# agc-integration-tests
2-
Integration tests for AGC
1+
# scc-integration-tests
2+
Integration tests for SCC
33

4-
These integration tests simulate basic and advanced scenarios that may be encountered in AGC.
4+
These integration tests simulate basic and advanced scenarios that may be encountered in SCC.
55
The goal of each test scenario is to spawn up a cluster and change its state while clients are simultaneously publishing and consuming channel data to/from various instances within that cluster.
66

77
To run the tests, you need to have Node.js and Docker installed - You should be able to run the `docker` command from your user account without sudo.
@@ -12,10 +12,10 @@ Then:
1212
3. Run `npm install`
1313
4. Run `npm test`
1414

15-
Note that if you've built an AGC architecture with some custom instances, you can swap out the default Docker images with your own images in `config.js`.
15+
Note that if you've built an SCC architecture with some custom instances, you can swap out the default Docker images with your own images in `config.js`.
1616

1717
If you find new failure scenarios that you would like someone to look at and/or resolve, feel free to open a pull request on this repo so that we can start working on a fix.
1818

1919
Please put long/complex test scenarios in a separate file under the `test/` directory.
2020

21-
The goal of this project is to help the Asyngular/SC community share solutions and to build up a comprehensive set of test scenarios to help everyone build more robust systems on top of the AGC architecture.
21+
The goal of this project is to help the SocketCluster/SC community share solutions and to build up a comprehensive set of test scenarios to help everyone build more robust systems on top of the SCC architecture.

client-indirect-publishers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let asyngularClient = require('asyngular-client');
1+
let socketClusterClient = require('socketcluster-client');
22
let argv = require('minimist')(process.argv.slice(2));
33

44
let options = JSON.parse(argv.options || '{}');
@@ -24,7 +24,7 @@ let c = 0;
2424

2525
for (let i = 0; i < clientCount; i++) {
2626
let intervalRandomness = Math.random() * publishRandomness;
27-
let socket = asyngularClient.create(clientOptions);
27+
let socket = socketClusterClient.create(clientOptions);
2828

2929
(async () => {
3030
for await (let {error} of socket.listener('error')) {

client-publishers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let asyngularClient = require('asyngular-client');
1+
let socketClusterClient = require('socketcluster-client');
22
let argv = require('minimist')(process.argv.slice(2));
33

44
let options = JSON.parse(argv.options || '{}');
@@ -24,7 +24,7 @@ let c = 0;
2424

2525
for (let i = 0; i < clientCount; i++) {
2626
let intervalRandomness = Math.random() * publishRandomness;
27-
let socket = asyngularClient.create(clientOptions);
27+
let socket = socketClusterClient.create(clientOptions);
2828

2929
(async () => {
3030
for await (let {error} of socket.listener('error')) {

client-subscribers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let asyngularClient = require('asyngular-client');
1+
let socketClusterClient = require('socketcluster-client');
22
let argv = require('minimist')(process.argv.slice(2));
33

44
let options = JSON.parse(argv.options || '{}');
@@ -22,7 +22,7 @@ let pendingSubscriptionPromises = [];
2222
let c = 0;
2323

2424
for (let i = 0; i < clientCount; i++) {
25-
let socket = asyngularClient.create(clientOptions);
25+
let socket = socketClusterClient.create(clientOptions);
2626

2727
(async () => {
2828
for await (let {error} of socket.listener('error')) {

config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ let path = require('path');
22

33
module.exports = {
44
state: {
5-
imageName: 'socketcluster/agc-state',
6-
versionTag: 'v6.0.0',
5+
imageName: 'socketcluster/scc-state',
6+
versionTag: 'v7.0.0',
77
internalContainerPort: 7777
88
},
99
worker: {
10-
imageName: 'socketcluster/asyngular',
11-
versionTag: 'v6.1.1',
10+
imageName: 'socketcluster/socketcluster',
11+
versionTag: 'v15.0.6',
1212
internalContainerPort: 8000
1313
},
1414
broker: {
15-
imageName: 'socketcluster/agc-broker',
16-
versionTag: 'v6.0.0',
15+
imageName: 'socketcluster/scc-broker',
16+
versionTag: 'v7.0.0',
1717
internalContainerPort: 8888
1818
},
1919
subscriberInstancePath: path.resolve(__dirname, 'client-subscribers.js'),

controllers/server.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
const http = require('http');
22
const eetase = require('eetase');
3-
const asyngularServer = require('asyngular-server');
3+
const socketClusterServer = require('socketcluster-server');
44
const express = require('express');
55
const serveStatic = require('serve-static');
66
const path = require('path');
77
const morgan = require('morgan');
88
const uuid = require('uuid');
9-
const agcBrokerClient = require('agc-broker-client');
9+
const sccBrokerClient = require('scc-broker-client');
1010

1111
const ENVIRONMENT = process.env.ENV || 'dev';
12-
const ASYNGULAR_PORT = process.env.ASYNGULAR_PORT || 8000;
13-
const ASYNGULAR_WS_ENGINE = process.env.ASYNGULAR_WS_ENGINE || 'ws';
14-
const ASYNGULAR_SOCKET_CHANNEL_LIMIT = Number(process.env.ASYNGULAR_SOCKET_CHANNEL_LIMIT) || 1000;
15-
const ASYNGULAR_LOG_LEVEL = process.env.ASYNGULAR_LOG_LEVEL || 2;
16-
17-
const AGC_INSTANCE_ID = uuid.v4();
18-
const AGC_STATE_SERVER_HOST = process.env.AGC_STATE_SERVER_HOST || null;
19-
const AGC_STATE_SERVER_PORT = process.env.AGC_STATE_SERVER_PORT || null;
20-
const AGC_MAPPING_ENGINE = process.env.AGC_MAPPING_ENGINE || null;
21-
const AGC_CLIENT_POOL_SIZE = process.env.AGC_CLIENT_POOL_SIZE || null;
22-
const AGC_AUTH_KEY = process.env.AGC_AUTH_KEY || null;
23-
const AGC_INSTANCE_IP = process.env.AGC_INSTANCE_IP || null;
24-
const AGC_INSTANCE_IP_FAMILY = process.env.AGC_INSTANCE_IP_FAMILY || null;
25-
const AGC_STATE_SERVER_CONNECT_TIMEOUT = Number(process.env.AGC_STATE_SERVER_CONNECT_TIMEOUT) || null;
26-
const AGC_STATE_SERVER_ACK_TIMEOUT = Number(process.env.AGC_STATE_SERVER_ACK_TIMEOUT) || null;
27-
const AGC_STATE_SERVER_RECONNECT_RANDOMNESS = Number(process.env.AGC_STATE_SERVER_RECONNECT_RANDOMNESS) || null;
28-
const AGC_PUB_SUB_BATCH_DURATION = Number(process.env.AGC_PUB_SUB_BATCH_DURATION) || null;
29-
const AGC_BROKER_RETRY_DELAY = Number(process.env.AGC_BROKER_RETRY_DELAY) || null;
12+
const SOCKETCLUSTER_PORT = process.env.SOCKETCLUSTER_PORT || 8000;
13+
const SOCKETCLUSTER_WS_ENGINE = process.env.SOCKETCLUSTER_WS_ENGINE || 'ws';
14+
const SOCKETCLUSTER_SOCKET_CHANNEL_LIMIT = Number(process.env.SOCKETCLUSTER_SOCKET_CHANNEL_LIMIT) || 1000;
15+
const SOCKETCLUSTER_LOG_LEVEL = process.env.SOCKETCLUSTER_LOG_LEVEL || 2;
16+
17+
const SCC_INSTANCE_ID = uuid.v4();
18+
const SCC_STATE_SERVER_HOST = process.env.SCC_STATE_SERVER_HOST || null;
19+
const SCC_STATE_SERVER_PORT = process.env.SCC_STATE_SERVER_PORT || null;
20+
const SCC_MAPPING_ENGINE = process.env.SCC_MAPPING_ENGINE || null;
21+
const SCC_CLIENT_POOL_SIZE = process.env.SCC_CLIENT_POOL_SIZE || null;
22+
const SCC_AUTH_KEY = process.env.SCC_AUTH_KEY || null;
23+
const SCC_INSTANCE_IP = process.env.SCC_INSTANCE_IP || null;
24+
const SCC_INSTANCE_IP_FAMILY = process.env.SCC_INSTANCE_IP_FAMILY || null;
25+
const SCC_STATE_SERVER_CONNECT_TIMEOUT = Number(process.env.SCC_STATE_SERVER_CONNECT_TIMEOUT) || null;
26+
const SCC_STATE_SERVER_ACK_TIMEOUT = Number(process.env.SCC_STATE_SERVER_ACK_TIMEOUT) || null;
27+
const SCC_STATE_SERVER_RECONNECT_RANDOMNESS = Number(process.env.SCC_STATE_SERVER_RECONNECT_RANDOMNESS) || null;
28+
const SCC_PUB_SUB_BATCH_DURATION = Number(process.env.SCC_PUB_SUB_BATCH_DURATION) || null;
29+
const SCC_BROKER_RETRY_DELAY = Number(process.env.SCC_BROKER_RETRY_DELAY) || null;
3030

3131
let agOptions;
3232

33-
if (process.env.ASYNGULAR_OPTIONS) {
34-
agOptions = JSON.parse(process.env.ASYNGULAR_OPTIONS);
33+
if (process.env.SOCKETCLUSTER_OPTIONS) {
34+
agOptions = JSON.parse(process.env.SOCKETCLUSTER_OPTIONS);
3535
} else {
3636
agOptions = {};
3737
}
3838

3939
let httpServer = eetase(http.createServer());
40-
let agServer = asyngularServer.attach(httpServer, agOptions);
40+
let agServer = socketClusterServer.attach(httpServer, agOptions);
4141

4242
let expressApp = express();
4343
if (ENVIRONMENT === 'dev') {
@@ -59,17 +59,17 @@ expressApp.get('/health-check', (req, res) => {
5959
}
6060
})();
6161

62-
if (ASYNGULAR_LOG_LEVEL >= 1) {
62+
if (SOCKETCLUSTER_LOG_LEVEL >= 1) {
6363
(async () => {
6464
for await (let {error} of agServer.listener('error')) {
6565
console.error(error);
6666
}
6767
})();
6868
}
6969

70-
if (ASYNGULAR_LOG_LEVEL >= 2) {
70+
if (SOCKETCLUSTER_LOG_LEVEL >= 2) {
7171
console.log(
72-
` ${colorText('[Active]', 32)} Asyngular worker with PID ${process.pid} is listening on port ${ASYNGULAR_PORT}`
72+
` ${colorText('[Active]', 32)} SocketCluster worker with PID ${process.pid} is listening on port ${SOCKETCLUSTER_PORT}`
7373
);
7474

7575
(async () => {
@@ -88,29 +88,29 @@ function colorText(message, color) {
8888

8989
let stats = {};
9090

91-
if (AGC_STATE_SERVER_HOST) {
92-
// Setup broker client to connect to the Asyngular cluster (AGC).
93-
let agcClient = agcBrokerClient.attach(agServer.brokerEngine, {
94-
instanceId: AGC_INSTANCE_ID,
95-
instancePort: ASYNGULAR_PORT,
96-
instanceIp: AGC_INSTANCE_IP,
97-
instanceIpFamily: AGC_INSTANCE_IP_FAMILY,
98-
pubSubBatchDuration: AGC_PUB_SUB_BATCH_DURATION,
99-
stateServerHost: AGC_STATE_SERVER_HOST,
100-
stateServerPort: AGC_STATE_SERVER_PORT,
101-
mappingEngine: AGC_MAPPING_ENGINE,
102-
clientPoolSize: AGC_CLIENT_POOL_SIZE,
103-
authKey: AGC_AUTH_KEY,
104-
stateServerConnectTimeout: AGC_STATE_SERVER_CONNECT_TIMEOUT,
105-
stateServerAckTimeout: AGC_STATE_SERVER_ACK_TIMEOUT,
106-
stateServerReconnectRandomness: AGC_STATE_SERVER_RECONNECT_RANDOMNESS,
107-
brokerRetryDelay: AGC_BROKER_RETRY_DELAY
91+
if (SCC_STATE_SERVER_HOST) {
92+
// Setup broker client to connect to the SocketCluster cluster (SCC).
93+
let sccClient = sccBrokerClient.attach(agServer.brokerEngine, {
94+
instanceId: SCC_INSTANCE_ID,
95+
instancePort: SOCKETCLUSTER_PORT,
96+
instanceIp: SCC_INSTANCE_IP,
97+
instanceIpFamily: SCC_INSTANCE_IP_FAMILY,
98+
pubSubBatchDuration: SCC_PUB_SUB_BATCH_DURATION,
99+
stateServerHost: SCC_STATE_SERVER_HOST,
100+
stateServerPort: SCC_STATE_SERVER_PORT,
101+
mappingEngine: SCC_MAPPING_ENGINE,
102+
clientPoolSize: SCC_CLIENT_POOL_SIZE,
103+
authKey: SCC_AUTH_KEY,
104+
stateServerConnectTimeout: SCC_STATE_SERVER_CONNECT_TIMEOUT,
105+
stateServerAckTimeout: SCC_STATE_SERVER_ACK_TIMEOUT,
106+
stateServerReconnectRandomness: SCC_STATE_SERVER_RECONNECT_RANDOMNESS,
107+
brokerRetryDelay: SCC_BROKER_RETRY_DELAY
108108
});
109109

110-
if (ASYNGULAR_LOG_LEVEL >= 1) {
110+
if (SOCKETCLUSTER_LOG_LEVEL >= 1) {
111111
(async () => {
112-
for await (let {error} of agcClient.listener('error')) {
113-
error.name = 'AGCError';
112+
for await (let {error} of sccClient.listener('error')) {
113+
error.name = 'SCCError';
114114
console.error(error);
115115
}
116116
})();
@@ -135,33 +135,33 @@ if (AGC_STATE_SERVER_HOST) {
135135
}
136136

137137
(async () => {
138-
for await (let data of agcClient.listener('subscribe')) {
138+
for await (let data of sccClient.listener('subscribe')) {
139139
handleEventData('subscribe', data);
140140
}
141141
})();
142142

143143
(async () => {
144-
for await (let data of agcClient.listener('subscribeFail')) {
144+
for await (let data of sccClient.listener('subscribeFail')) {
145145
handleEventData('subscribeFail', data);
146146
}
147147
})();
148148

149149
(async () => {
150-
for await (let data of agcClient.listener('publish')) {
150+
for await (let data of sccClient.listener('publish')) {
151151
handleEventData('publish', data);
152152
}
153153
})();
154154

155155
(async () => {
156-
for await (let data of agcClient.listener('publishFail')) {
156+
for await (let data of sccClient.listener('publishFail')) {
157157
handleEventData('publishFail', data);
158158
}
159159
})();
160160

161161
// ---- End stats collections ----
162162
}
163163

164-
// Asyngular/WebSocket connection handling loop.
164+
// SocketCluster/WebSocket connection handling loop.
165165
(async () => {
166166
for await (let {socket} of agServer.listener('connection')) {
167167
// Handle socket connection.
@@ -182,4 +182,4 @@ if (AGC_STATE_SERVER_HOST) {
182182
}
183183
})();
184184

185-
httpServer.listen(ASYNGULAR_PORT);
185+
httpServer.listen(SOCKETCLUSTER_PORT);

0 commit comments

Comments
 (0)