Skip to content

Commit

Permalink
Merge 1e7cbaa into 516fbfc
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserf committed Feb 8, 2020
2 parents 516fbfc + 1e7cbaa commit 7cde132
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -41,7 +41,7 @@ matrix:
script:
- npm run lint;
- npm run test:all:coverage;
- npm run e2e:uws || true;
- npm run e2e:uws;
# These tests don't pass on CI
- npm run e2e:v3 || true;
- npm run e2e:uws:v3 || true;
Expand Down
3 changes: 2 additions & 1 deletion test-e2e/framework/client.ts
Expand Up @@ -126,7 +126,8 @@ export const client = {
} else {
sinon.assert.called(spy)
}
if (data !== undefined) {
if (data !== null) {
console.log(data)
sinon.assert.calledWith(spy, JSON.parse(data))
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/steps/client/record-steps.ts
Expand Up @@ -112,7 +112,7 @@ Given(/^(.+) asks? if record "([^"]*)" exists$/, (clientExpression: string, reco
})

Then(/^(.+) gets? told record "([^"]*)" (.*)exists?$/, (clientExpression: string, recordName: string, adjective) => {
record.assert.has(clientExpression, recordName, adjective.indexOf('not') === -1)
record.assert.has(clientExpression, recordName, (adjective || '').indexOf('not') === -1)
})

Then(/^(.+) asks? for the version of record "([^"]*)"$/, (clientExpression: string, recordName: string, done) => {
Expand Down
39 changes: 19 additions & 20 deletions test-e2e/steps/http/http-steps.ts
Expand Up @@ -76,14 +76,13 @@ When(/^(.+) queues? (?:an|the|"(\d+)") events? "([^"]*)"(?: with data ("[^"]*"|\
topic: 'event',
action: 'emit',
eventName,
data: undefined
data: null
}
if (rawData !== undefined) {
if (rawData !== null) {
jifMessage.data = parseData(rawData)
}
if (numEvents === undefined) {
if (numEvents === null) {
client.queue.push(jifMessage)

} else {
for (let i = 0; i < numEvents; i++) {
client.queue.push(jifMessage)
Expand Down Expand Up @@ -175,9 +174,9 @@ When(/^(.+) queues? (?:an|the) RPC call to "([^"]*)"(?: with arguments ("[^"]*"|
topic: 'rpc',
action: 'make',
rpcName,
data: undefined
data: null
}
if (rawData !== undefined) {
if (rawData !== null) {
jifMessage.data = parseData(rawData)
}

Expand All @@ -203,15 +202,15 @@ When(/^(.+) queues? a write to (record|list) "([^"]*)"(?: and path "([^"]*)")? w
? { topic: 'record', action: 'write', recordName }
: { topic: 'list', action: 'write', listName: recordName }

if (path !== undefined) {
if (path !== null) {
// @ts-ignore
jifMessage.path = path
}
if (rawData !== undefined) {
if (rawData !== null) {
// @ts-ignore
jifMessage.data = parseData(rawData)
}
if (version !== undefined) {
if (version !== null) {
// @ts-ignore
jifMessage.version = parseInt(version, 10)
}
Expand Down Expand Up @@ -261,15 +260,15 @@ When(/^(.+) flushe?s? their http queues?$/, (clientExpression: string, done) =>
}
client.queue = []
needle.post(`${client.serverUrl}`, message, { json: true }, (err, response) => {
setTimeout(done, defaultDelay)
client.lastResponse = response
setTimeout(done, defaultDelay)
})
})
})

Then(/^(.+) last response said that clients? "([^"]*)" (?:is|are) connected(?: at index "(\d+)")?$/, (clientExpression: string, connectedClients, rawIndex) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand All @@ -285,7 +284,7 @@ Then(/^(.+) last response said that clients? "([^"]*)" (?:is|are) connected(?: a

Then(/^(.+) last response said that no clients are connected(?: at index "(\d+)")?$/, (clientExpression: string, rawIndex) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand All @@ -301,7 +300,7 @@ Then(/^(.+) last response said that no clients are connected(?: at index "(\d+)"

Then(/^(.+) receives? an RPC response(?: with data ("[^"]*"|\d+|{.*}))?(?: at index "(\d+)")?$/, (clientExpression: string, rawData, rawIndex) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand All @@ -311,15 +310,15 @@ Then(/^(.+) receives? an RPC response(?: with data ("[^"]*"|\d+|{.*}))?(?: at in
const result = lastResponse.body.body[responseIndex]
expect(result).to.be.an('object')
expect(result.success).to.equal(true)
if (rawData !== undefined) {
if (rawData !== null && rawData !== '"undefined"') {
expect(result.data).to.deep.equal(parseData(rawData))
}
})
})

Then(/^(.+) receives? the (?:record|list) (?:head )?"([^"]*)"(?: with data '([^']+)')?(?: (?:with|and) version "(\d+)")?(?: at index "(\d+)")?$/, (clientExpression: string, recordName: string, rawData, version, rawIndex) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand All @@ -329,10 +328,10 @@ Then(/^(.+) receives? the (?:record|list) (?:head )?"([^"]*)"(?: with data '([^'
const result = lastResponse.body.body[responseIndex]
expect(result).to.be.an('object')
expect(result.success).to.equal(true)
if (rawData !== undefined) {
if (rawData !== null) {
expect(result.data).to.deep.equal(parseData(rawData))
}
if (version !== undefined) {
if (version !== null) {
expect(result.version).to.equal(parseInt(version, 10))
}
})
Expand All @@ -347,7 +346,7 @@ Then(/^(.+) last response was a "(\S*)"(?: with length "(\d+)")?$/, (clientExpre
const failuresStr = JSON.stringify(failures, null, 2)
expect(lastResponse.body.result).to.equal(result, failuresStr)

if (length !== undefined) {
if (length !== null) {
expect(lastResponse.body.body.length).to.equal(parseInt(length, 10))
}

Expand All @@ -371,7 +370,7 @@ Then(/^(.+) (eventually )?receives "(\d+)" events? "([^"]*)"(?: with data (.+))?

Then(/^(.+) last response had a success(?: at index "(\d+)")?$/, (clientExpression: string, rawIndex) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand All @@ -389,7 +388,7 @@ Then(/^(.+) last response had a success(?: at index "(\d+)")?$/, (clientExpressi

Then(/^(.+) last response had an? "([^"]*)" error matching "([^"]*)"(?: at index "(\d+)")?$/, (clientExpression: string, topic: string, message: string, rawIndex: number) => {
clientHandler.getClientNames(clientExpression).forEach((clientName: string) => {
const responseIndex = rawIndex === undefined ? 0 : rawIndex
const responseIndex = rawIndex === null ? 0 : rawIndex
const client = httpClients[clientName]
const lastResponse = client.lastResponse

Expand Down
2 changes: 1 addition & 1 deletion test-e2e/tools/e2e-cluster-node.ts
Expand Up @@ -23,7 +23,7 @@ export class E2EClusterNode extends DeepstreamPlugin implements DeepstreamCluste
process.nextTick(() => {
for (const [serverName, emitter] of E2EClusterNode.emitters) {
if (serverName !== this.config.serverName) {
emitter.emit(TOPIC[message.topic], this.config.serverName, msg)
emitter.emit(TOPIC[message.topic], this.config.serverName, { ...msg })
}
}
})
Expand Down

0 comments on commit 7cde132

Please sign in to comment.