|
4 | 4 | AioHTTPTestCase, |
5 | 5 | unittest_run_loop, |
6 | 6 | ) |
7 | | -import time |
8 | 7 | from minos.api_gateway.common import ( |
9 | 8 | MinosConfig, |
10 | 9 | ) |
11 | 10 | from minos.api_gateway.discovery import ( |
12 | 11 | DiscoveryService, |
13 | 12 | ) |
14 | | -from tests.test_api_gateway.test_discovery.dataset import generate_record, generate_random_microservice_names |
| 13 | +from tests.test_api_gateway.test_discovery.dataset import generate_record, generate_random_microservice_names, \ |
| 14 | + generate_record_old |
15 | 15 | from tests.utils import ( |
16 | 16 | BASE_PATH, |
17 | 17 | ) |
@@ -80,6 +80,42 @@ async def test_bulk_update(self): |
80 | 80 | self.assertEqual(record['body']['port'], int(body["port"])) |
81 | 81 | self.assertEqual(record['name'], body["name"]) |
82 | 82 |
|
| 83 | + async def test_bulk_update_2(self): |
| 84 | + expected = list() |
| 85 | + tasks = list() |
| 86 | + # Create new records |
| 87 | + for x in range(50): |
| 88 | + name, body = generate_record_old(x) |
| 89 | + tasks.append(self.client.post(f"/microservices/{name}", json=body)) |
| 90 | + |
| 91 | + results = await asyncio.gather(*tasks) |
| 92 | + |
| 93 | + for result in results: |
| 94 | + self.assertEqual(201, result.status) |
| 95 | + |
| 96 | + tasks = list() |
| 97 | + for x in range(50): |
| 98 | + name, body = generate_record_old(x) |
| 99 | + expected.append({"name": name, "path": f"/microservices/{name}", "body": body}) |
| 100 | + tasks.append(self.client.post(f"/microservices/{name}", json=body)) |
| 101 | + |
| 102 | + results = await asyncio.gather(*tasks) |
| 103 | + |
| 104 | + for result in results: |
| 105 | + self.assertEqual(201, result.status) |
| 106 | + |
| 107 | + for record in expected: |
| 108 | + response = await self.client.get( |
| 109 | + f"/microservices?verb={record['body']['endpoints'][0][0]}&path={record['body']['endpoints'][0][1]}") |
| 110 | + |
| 111 | + self.assertEqual(200, response.status) |
| 112 | + |
| 113 | + body = await response.json() |
| 114 | + |
| 115 | + self.assertEqual(record['body']['address'], body["address"]) |
| 116 | + self.assertEqual(int(record['body']['port']), int(body["port"])) |
| 117 | + self.assertEqual(record['name'], body["name"]) |
| 118 | + |
83 | 119 | @unittest_run_loop |
84 | 120 | async def test_post_missing_param(self): |
85 | 121 | name = "test_name" |
|
0 commit comments