add test for distribution ip

pull/37/head
Minh Doan 6 years ago
parent 65f1782f8e
commit e35df38fd4
  1. 1
      .gitignore
  2. 5
      aws-experiment-launch/utils/utils.py
  3. 31
      aws-experiment-launch/utils/utils_test.py

1
.gitignore vendored

@ -6,6 +6,7 @@
# Executables
harmony-benchmark
*.pyc
*.exe
*.out
*.app

@ -58,5 +58,6 @@ def generate_distribution_config(shard_num, client_num, ip_list, config_filename
validator_id = validator_id + 1
if __name__ == "__main__":
ip_list = collect_public_ips('4', "4-NODE-14-46-47-2018-07-05", "configuration.txt")
generate_distribution_config(2, 2, ip_list, "config_test.txt")
ip_list = collect_public_ips('4', "4-NODE-23-36-01-2018-07-05", "configuration.txt")
print ip_list
generate_distribution_config(2, 1, ip_list, "config_test.txt")

@ -0,0 +1,31 @@
import unittest
from utils import generate_distribution_config
class TestCreateAndDeploy(unittest.TestCase):
def test_generate_config_file(self):
ips = ["102.000.000.1", "102.000.000.2", "102.000.000.3", "102.000.000.4", "102.000.000.5", "102.000.000.6"]
generate_distribution_config(2, 2, ips, "config_test.txt")
with open("config_test.txt", "r") as fin:
lines = fin.readlines()
collection = {}
collection['ip'] = []
collection['client'] = {}
leader_count, validator_count, client_count = 0, 0, 0
for line in lines:
strs = line.split(" ")
assert(not strs[0] in collection['ip'])
collection['ip'].append(strs[0])
if strs[2] == "client":
client_count = client_count + 1
elif strs[2] == "leader":
leader_count = leader_count + 1
elif strs[2] == "validator":
validator_count = validator_count + 1
assert(validator_count == 2)
assert(leader_count == 2)
assert(client_count == 2)
if __name__ == '__main__':
unittest.main()
Loading…
Cancel
Save