def test_should_decorate_directors_tag_with_enabled_directors_in_current_dc(self): vcl_tag_builder_for_dc2 = VclTagBuilder(self.varnish, VclRendererInput()) vcl_tag_builder_for_dc1 = VclTagBuilder(self.varnish_dc1, VclRendererInput()) expected_dc2_directors = [ 'first_service', 'second_service', 'third_service', 'fifth_director_only_cluster1_siteA_test', 'fourth_director_which_has_a_ridiculously_long_name' ] expected_dc1_directors = [ 'second_service', 'third_service', 'fifth_director_only_cluster1_siteA_test', 'fourth_director_which_has_a_ridiculously_long_name' ] self.assert_vcl_tag_list_contains_directors_list( vcl_tag_builder_for_dc2.get_expanded_tags('DIRECTORS')[0].parameters['vcl_directors'], expected_dc2_directors) self.assert_vcl_tag_list_contains_directors_list( vcl_tag_builder_for_dc1.get_expanded_tags('DIRECTORS')[0].parameters['vcl_directors'], expected_dc1_directors)
def test_should_build_tag_names_based_on_directors_and_dc(self): vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) tags = vcl_tag_builder.get_expanded_tags('BACKEND_DEFINITION_LIST_{DIRECTOR}_{DC}') self.assert_vcl_tag(tags[0], 'third_service', 'dc1') self.assert_vcl_tag(tags[1], 'fourth_director_which_has_a_ridiculously_long_name', 'dc1') self.assert_vcl_tag(tags[2], 'first_service', 'dc2') self.assert_vcl_tag(tags[3], 'second_service', 'dc2') self.assert_vcl_tag(tags[4], 'second_service', 'dc1') self.assert_vcl_tag(tags[5], 'fifth_director_only_cluster1_siteA_test', 'dc1')
def test_should_decorate_directors_tag_with_example_active_active_director(self): active_active_director = 'second_service' expected_datacenters = ['dc2', 'dc1'] vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) active_director_datacenters = [] for vcl_director in vcl_tag_builder.get_expanded_tags('DIRECTORS')[0].parameters['vcl_directors']: if vcl_director.director.name == active_active_director: active_director_datacenters.append(vcl_director.dc.symbol) assert_list_equal(expected_datacenters, active_director_datacenters)
def test_should_build_tag_names_based_on_directors_and_dc(self): vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) tags = vcl_tag_builder.get_expanded_tags( 'BACKEND_DEFINITION_LIST_{DIRECTOR}_{DC}') self.assert_vcl_tag(tags[0], 'third_service', 'dc1') self.assert_vcl_tag( tags[1], 'fourth_director_which_has_a_ridiculously_long_name', 'dc1') self.assert_vcl_tag(tags[2], 'first_service', 'dc2') self.assert_vcl_tag(tags[3], 'second_service', 'dc2') self.assert_vcl_tag(tags[4], 'second_service', 'dc1') self.assert_vcl_tag(tags[5], 'fifth_director_only_cluster1_siteA_test', 'dc1')
def test_should_decorate_set_backend_tag_with_ordered_director_list_in_second_dc(self): active_active_director = 'second_service' expected_datacenters = ['dc1', 'dc2'] vcl_tag_builder = VclTagBuilder(self.varnish_dc1, VclRendererInput()) active_director_datacenters = [] for tag in vcl_tag_builder.get_expanded_tags('SET_BACKEND_{DIRECTOR}'): if tag.parameters['director'].name == active_active_director: for vcl_director in tag.parameters['vcl_directors']: active_director_datacenters.append(vcl_director.dc.symbol) break assert_list_equal(expected_datacenters, active_director_datacenters)
def test_should_decorate_set_backend_tag_with_ordered_director_list_in_second_dc( self): active_active_director = 'second_service' expected_datacenters = ['dc1', 'dc2'] vcl_tag_builder = VclTagBuilder(self.varnish_dc1, VclRendererInput()) active_director_datacenters = [] for tag in vcl_tag_builder.get_expanded_tags('SET_BACKEND_{DIRECTOR}'): if tag.parameters['director'].name == active_active_director: for vcl_director in tag.parameters['vcl_directors']: active_director_datacenters.append(vcl_director.dc.symbol) break assert_list_equal(expected_datacenters, active_director_datacenters)
def test_should_decorate_directors_tag_with_example_active_active_director( self): active_active_director = 'second_service' expected_datacenters = ['dc2', 'dc1'] vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) active_director_datacenters = [] for vcl_director in vcl_tag_builder.get_expanded_tags( 'DIRECTORS')[0].parameters['vcl_directors']: if vcl_director.director.name == active_active_director: active_director_datacenters.append(vcl_director.dc.symbol) assert_list_equal(expected_datacenters, active_director_datacenters)
def test_should_decorate_directors_tag_with_enabled_directors_in_current_cluster( self): vcl_tag_builder_for_dc2 = VclTagBuilder(self.varnish4, VclRendererInput()) expected_dc2_second_cluster_directors = [ 'first_service', 'second_service', 'third_service', 'fourth_director_which_has_a_ridiculously_long_name' ] self.assert_vcl_tag_list_contains_directors_list( vcl_tag_builder_for_dc2.get_expanded_tags( 'DIRECTORS')[0].parameters['vcl_directors'], expected_dc2_second_cluster_directors)
def test_should_decorate_set_backend_tag_with_fallback_service_in_dc1(self): fallback_director = 'fifth_director_only_cluster1_siteA_test' expected_datacenters = ['dc1'] vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) active_director_datacenters = [] for tag in vcl_tag_builder.get_expanded_tags('SET_BACKEND_{DIRECTOR}'): if tag.parameters['director'].name == fallback_director: for vcl_director in tag.parameters['vcl_directors']: active_director_datacenters.append(vcl_director.dc.symbol) break assert_list_equal(expected_datacenters, active_director_datacenters)
def test_should_decorate_set_backend_tag_with_fallback_service_in_dc1( self): fallback_director = 'fifth_director_only_cluster1_siteA_test' expected_datacenters = ['dc1'] vcl_tag_builder = VclTagBuilder(self.varnish, VclRendererInput()) active_director_datacenters = [] for tag in vcl_tag_builder.get_expanded_tags('SET_BACKEND_{DIRECTOR}'): if tag.parameters['director'].name == fallback_director: for vcl_director in tag.parameters['vcl_directors']: active_director_datacenters.append(vcl_director.dc.symbol) break assert_list_equal(expected_datacenters, active_director_datacenters)