예제 #1
0
 def test_cluster_call_and_get_better_availability(self):
     service = Service(50, 100)
     cluster = Cluster(service, 2)
     for _ in range(0, 100000):
         cluster.call()
         service.call()
     self.assertLess(cluster.get_failed_count(), service.get_failed_count())
예제 #2
0
    def test_cluster_with_dependencies(self):
        dependency = TestService.create_service_which_always_fails()
        service = TestService.create_service_which_always_succeeds()
        cluster = Cluster(service, 100)
        service.add_dependency(dependency)
        result = cluster.call()
        self.assertEqual(result, Call.FAIL)


# call() can be made only on roots
예제 #3
0
def main():
    # Configuring microservice structure
    service = Service(50, 100, 'service')
    cluster = Cluster(service, 2)
    # Simulating calls in cycles
    cycles = 100000
    for _ in range(cycles):
        cluster.call()
    # Drawing from root
    draw = Draw()
    draw.draw_any(cluster)
예제 #4
0
def main():
    # Configuring microservice structure
    service = Service(5, 100, 'service')
    database = Service(5, 100, 'database')
    service.add_dependency(database)
    cluster = Cluster(service, 5)
    # Simulating calls in cycles
    cycles = 100000
    for _ in range(cycles):
        cluster.call()
    # Drawing from root
    draw = Draw()
    draw.draw_tree(cluster)
예제 #5
0
def main():
    # Configuring microservice structure
    services = []
    maximum_number_of_services = 10
    broker = Service(5, 100, 'broker')
    broker_cluster = Cluster(broker, 2)
    for i in range(1, maximum_number_of_services + 1):
        service = Service(5, 100,
                          'service-%d' % (maximum_number_of_services - i + 1))
        service.add_dependency(broker_cluster)
        services.append(service)
    # Simulating calls in cycles
    cycles = 1000000
    for _ in range(cycles):
        for service in services:
            service.call()
    # Drawing from root
    draw = Draw()
    draw.draw_each(services)
예제 #6
0
 def test_cluster_self_availability_percentage(self):
     service = TestService.create_service_which_always_fails()
     cluster = Cluster(service, 1)
     self.assertEqual(100, cluster.get_self_availability_percentage())
예제 #7
0
 def test_cluster_call_and_fail(self):
     service = TestService.create_service_which_always_fails()
     cluster = Cluster(service, 1)
     result = cluster.call()
     self.assertEqual(result, Call.FAIL)
예제 #8
0
 def test_cluster_call_and_succeed(self):
     service = TestService.create_service_which_always_succeeds()
     cluster = Cluster(service, 1)
     result = cluster.call()
     self.assertEqual(result, Call.PASS)
예제 #9
0
def main():
    # Configuring microservice structure
    proxy = Cluster(Service(5, 100, 'proxy'), 10)
    aggregate = Cluster(Service(5, 100, 'aggregate'), 5)
    app = Cluster(Service(5, 100, 'app'), 2)
    another_app = Cluster(Service(5, 100, 'another_app'), 3)
    database = Service(5, 100, 'database')
    another_app_db = Service(5, 100, 'database')
    cache = Service(5, 100, 'cache')
    proxy.add_dependency(aggregate)
    aggregate.add_dependency(app)
    aggregate.add_dependency(another_app)
    app.add_dependency(database)
    app.add_dependency(cache)
    another_app.add_dependency(cache)
    another_app.add_dependency(another_app_db)
    # Simulating calls in cycles
    cycles = 100000
    for _ in range(cycles):
        proxy.call()
    # Drawing from root
    draw = Draw()
    draw.draw_tree(proxy)