Add integration testing of commands

Add testing of the clusterctl commands against the master and slave
code.
This commit is contained in:
Hornwitser committed 2019-11-30 00:08:10 +01:00
1 parent b24c129e38
commit 3be264c9a9
6 files changed
+192 -1

No files matched your search

+54
View File
@@ -170,6 +170,60 @@ class SocketIOClientConnector extends events.EventEmitter {
}
}
class VirtualConnector extends events.EventEmitter {
constructor() {
super();
this.other = this;
this._seq = 1;
}
/**
* Create a pair of virtual connector hooked into each other
*
* Creates two virtual connectors that are liked to each othes such that
* a message sent on one is received by the other.
*
* @returns {Array} two virtuarl connectors.
*/
static makePair() {
let first = new this();
let second = new this();
first.other = second;
second.other = first;
return [first, second];
}
/**
* Send a message to the other end of the connector
*
* @returns the sequence number of the message sent
*/
send(type, data) {
this.other.emit('message', { seq: this._seq, type, data });
return this._seq++;
}
/**
* Close the connection with the given reason.
*
* Sends a close message to the other end of the connector with the
* given reason. Doesn't actually disconnect as virtual connectors
* doen't have a concept of disconnecting.
*/
close(reason) {
this.send('close', { reason });
}
/**
* Does nothing
*
* Virtual connectors do not have a concept of disconnecting.
*/
disconnect() { }
}
module.exports = {
SocketIOClientConnector,
VirtualConnector,
};
+2 -1
View File
@@ -40,7 +40,8 @@ class Link {
});
this.setHandler('close', message => {
this.connector.disconnect(message.data.reason);
console.log(`SOCKET | Received close: ${message.data.reason}`);
this.connector.disconnect();
}, schema.close);
}