Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switching communication through pubsubshare library
- Loading branch information
salboaie
committed
Aug 17, 2015
1 parent
41e4b43
commit 1000abc
Showing
12 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
- Launched when a node is started to make sure that only one adapter is executing commands | ||
- Launched also to make active a redundant node | ||
*/ | ||
var fileTransferTest = { | ||
startFileTransfer:function () { | ||
console.log("Starting fileTransferTest"); | ||
this.swarm("node1Phase"); | ||
}, | ||
node1Phase:{ | ||
node:"Node1", | ||
code:function () { | ||
var filename = swarmTempFile.async(); | ||
var self = this; | ||
(function(filename){ | ||
self.fileName = filename; | ||
self.fileContent = "Test content"; | ||
require("fs").writeFileSync(filename, self.fileContent); | ||
self.shareFile(self.fileName, "node2Confirm"); | ||
}).swait(filename); | ||
} | ||
}, | ||
node2Confirm:{ | ||
node:"Node2", | ||
do:function () { | ||
//waked up when transfer was done | ||
console.log("File: ", this.fileName, " from Node1 is now available for node2 as ", this.__transferId); | ||
var fileName = "tmp/"+this.__transferId; | ||
var self = this; | ||
this.download(this.__transferId, fileName, function(err, res){ | ||
if(require("fs").readFileSync(fileName) == self.fileContent){ | ||
self.result = "Passed"; | ||
} else { | ||
self.result = "Failed"; | ||
} | ||
fs.unlink(fileName); | ||
fs.unlink(self.fileName); | ||
self.home("result"); | ||
}) | ||
} | ||
} | ||
} | ||
|
||
fileTransferTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
var adapterPort = 3000; | ||
var adapterHost = "localhost"; | ||
var assert = require('semantic-firewall').assert; | ||
var util = require("swarmcore"); | ||
|
||
var client = util.createClient(adapterHost, adapterPort, "BenchmarkUser", "ok","BenchmarkTest", "testCtor"); | ||
|
||
|
||
assert.begin("Testing file transfers..."); | ||
|
||
assert.callback("File transfer between Node1 and Node2 ", function(callback){ | ||
client.startSwarm("FileTransferTest.js","startFileTransfer"); | ||
client.on("FileTransferTest.js",getResults); | ||
var msg = "none"; | ||
function getResults(obj){ | ||
msg = obj.result; | ||
assert.equal(msg,"Passed"); | ||
callback(); | ||
client.logout(); | ||
} | ||
}) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Do not delete. Used in tests. |