def install(cls, mh): super(TestServerDel, cls).install(mh) # prepare topologysegments for negative test cases # it should look like this for DOMAIN_SUFFIX_NAME: # master # / # / # / # replica1------- replica2 # and like this for CA_SUFFIX_NAME # master # \ # \ # \ # replica1------- replica2 tasks.create_segment(cls.client, cls.replica1, cls.replica2) tasks.create_segment(cls.client, cls.replica1, cls.replica2, suffix=CA_SUFFIX_NAME) # try to delete all relevant segment connecting master and replica1/2 segment_name_fmt = '{p[0].hostname}-to-{p[1].hostname}' for domain_pair in permutations((cls.master, cls.replica2)): tasks.destroy_segment(cls.client, segment_name_fmt.format(p=domain_pair)) for ca_pair in permutations((cls.master, cls.replica1)): tasks.destroy_segment(cls.client, segment_name_fmt.format(p=ca_pair), suffix=CA_SUFFIX_NAME)
def install(cls, mh): super(TestServerDel, cls).install(mh) # prepare topologysegments for negative test cases # it should look like this for DOMAIN_SUFFIX_NAME: # master # / # / # / # replica1------- replica2 # and like this for CA_SUFFIX_NAME # master # \ # \ # \ # replica1------- replica2 tasks.create_segment(cls.client, cls.replica1, cls.replica2) tasks.create_segment(cls.client, cls.replica1, cls.replica2, suffix=CA_SUFFIX_NAME) # try to delete all relevant segment connecting master and replica1/2 segment_name_fmt = '{p[0].hostname}-to-{p[1].hostname}' for domain_pair in permutations((cls.master, cls.replica2)): tasks.destroy_segment( cls.client, segment_name_fmt.format(p=domain_pair)) for ca_pair in permutations((cls.master, cls.replica1)): tasks.destroy_segment( cls.client, segment_name_fmt.format(p=ca_pair), suffix=CA_SUFFIX_NAME)
def test_remove_the_only_connection(self): """ Testcase: http://www.freeipa.org/page/V4/Manage_replication_topology/ Test_plan#Test_case: _Removal_of_a_topology_segment_is_allowed_only_if_there_is_at_least_one_more_segment_connecting_the_given_replica """ text = "Removal of Segment disconnects topology" error1 = "The system should not have let you remove the segment" error2 = "Wrong error message thrown during segment removal: \"%s\"" replicas = (self.replicas[0].hostname, self.replicas[1].hostname) returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode != 0, error1 assert error.count(text) == 1, error2 % error _newseg, err = tasks.create_segment( self.master, self.master, self.replicas[1]) assert err == "", err returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode == 0, error
def test_remove_the_only_connection(self): """ Testcase: http://www.freeipa.org/page/V4/Manage_replication_topology/ Test_plan#Test_case: _Removal_of_a_topology_segment_is_allowed_only_if_there_is_at_least_one_more_segment_connecting_the_given_replica """ text = "Removal of Segment disconnects topology" error1 = "The system should not have let you remove the segment" error2 = "Wrong error message thrown during segment removal: \"%s\"" replicas = (self.replicas[0].hostname, self.replicas[1].hostname) returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode != 0, error1 assert error.count(text) == 1, error2 % error _newseg, err = tasks.create_segment( self.master, self.master, self.replicas[1]) assert err == "", err returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas) assert returncode == 0, error
def test_add_remove_segment(self): """ Make sure a topology segment can be manually created and deleted with the influence on the real topology Testcase http://www.freeipa.org/page/V4/Manage_replication_topology/ Test_plan#Test_case:_Basic_CRUD_test """ tasks.kinit_admin(self.master) # Install the second replica tasks.install_replica(self.master, self.replicas[1], setup_ca=False, setup_dns=False) # turn a star into a ring segment, err = tasks.create_segment(self.master, self.replicas[0], self.replicas[1]) assert err == "", err # Make sure the new segment is shown by `ipa topologysegment-find` result1 = self.master.run_command( ['ipa', 'topologysegment-find', DOMAIN_SUFFIX_NAME]).stdout_text assert (segment['name'] in result1), ("%s: segment not found" % segment['name']) # Remove master <-> replica2 segment and make sure that the changes get # there through replica1 # Since segment name can be one of master-to-replica2 or # replica2-to-master, we need to determine the segment name dynamically deleteme = find_segment(self.master, self.replicas[1]) returncode, error = tasks.destroy_segment(self.master, deleteme) assert returncode == 0, error # Wait till replication ends and make sure replica1 does not have # segment that was deleted on master replica1_ldap = self.replicas[0].ldap_connect() tasks.wait_for_replication(replica1_ldap) result3 = self.replicas[0].run_command( ['ipa', 'topologysegment-find', DOMAIN_SUFFIX_NAME]).stdout_text assert (deleteme not in result3), "%s: segment still exists" % deleteme # Create test data on master and make sure it gets all the way down to # replica2 through replica1 self.master.run_command([ 'ipa', 'user-add', 'someuser', '--first', 'test', '--last', 'user' ]) dest_ldap = self.replicas[1].ldap_connect() tasks.wait_for_replication(dest_ldap) result4 = self.replicas[1].run_command(['ipa', 'user-find']) assert ('someuser' in result4.stdout_text), 'User not found: someuser'
def test_add_remove_segment(self): """ Make sure a topology segment can be manually created and deleted with the influence on the real topology Testcase http://www.freeipa.org/page/V4/Manage_replication_topology/ Test_plan#Test_case:_Basic_CRUD_test """ tasks.kinit_admin(self.master) # Install the second replica tasks.install_replica(self.master, self.replicas[1], setup_ca=False, setup_dns=False) # turn a star into a ring segment, err = tasks.create_segment(self.master, self.replicas[0], self.replicas[1]) assert err == "", err # Make sure the new segment is shown by `ipa topologysegment-find` result1 = self.master.run_command(['ipa', 'topologysegment-find', DOMAIN_SUFFIX_NAME]).stdout_text assert(segment['name'] in result1), ( "%s: segment not found" % segment['name']) # Remove master <-> replica2 segment and make sure that the changes get # there through replica1 # Since segment name can be one of master-to-replica2 or # replica2-to-master, we need to determine the segment name dynamically deleteme = find_segment(self.master, self.replicas[1]) returncode, error = tasks.destroy_segment(self.master, deleteme) assert returncode == 0, error # Wait till replication ends and make sure replica1 does not have # segment that was deleted on master master_ldap = self.master.ldap_connect() tasks.wait_for_replication(master_ldap) result3 = self.replicas[0].run_command(['ipa', 'topologysegment-find', DOMAIN_SUFFIX_NAME]).stdout_text assert(deleteme not in result3), "%s: segment still exists" % deleteme # Create test data on master and make sure it gets all the way down to # replica2 through replica1 self.master.run_command(['ipa', 'user-add', 'someuser', '--first', 'test', '--last', 'user']) tasks.wait_for_replication(master_ldap) result4 = self.replicas[1].run_command(['ipa', 'user-find']) assert('someuser' in result4.stdout_text), 'User not found: someuser'
def test_replica_manage_commands(self): """ TestCase: http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan #Test_case:_ipa-replica-manage_connect_is_deprecated_in_domain_level_1 """ master = self.master replica1 = self.replicas[0] replica2 = self.replicas[1] result1 = master.run_command([ "ipa-replica-manage", "connect", replica1.hostname, replica2.hostname ], raiseonerr=False) assert result1.returncode == 0, result1.stderr_text result2 = master.run_command([ "ipa-replica-manage", "disconnect", replica1.hostname, replica2.hostname ], raiseonerr=False) assert result2.returncode == 0, result2.stderr_text master.run_command(["ipa", "domainlevel-set", str(DOMAIN_LEVEL_1)]) result3 = master.run_command([ "ipa-replica-manage", "connect", replica1.hostname, replica2.hostname ], raiseonerr=False) assert_error( result3, 'Creation of IPA replication agreement is' ' deprecated with managed IPA replication' ' topology. Please use `ipa topologysegment-*`' ' commands to manage the topology', 1) segment = tasks.create_segment(master, replica1, replica2) result4 = master.run_command([ "ipa-replica-manage", "disconnect", replica1.hostname, replica2.hostname ], raiseonerr=False) assert_error( result4, 'Removal of IPA replication agreement is' ' deprecated with managed IPA replication' ' topology. Please use `ipa topologysegment-*`' ' commands to manage the topology', 1) # http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan #Test_case:_ipa-csreplica-manage_connect_is_deprecated #_in_domain_level_1 result5 = master.run_command([ 'ipa-csreplica-manage', 'del', replica1.hostname, '-p', master.config.dirman_password ], raiseonerr=False) assert_error( result5, "Removal of IPA CS replication agreement" " and replication data is deprecated with" " managed IPA replication topology", 1) tasks.destroy_segment(master, segment[0]['name']) result6 = master.run_command([ "ipa-csreplica-manage", "connect", replica1.hostname, replica2.hostname, '-p', master.config.dirman_password ], raiseonerr=False) assert_error( result6, "Creation of IPA CS replication agreement is" " deprecated with managed IPA replication" " topology", 1) tasks.create_segment(master, replica1, replica2) result7 = master.run_command([ "ipa-csreplica-manage", "disconnect", replica1.hostname, replica2.hostname, '-p', master.config.dirman_password ], raiseonerr=False) assert_error( result7, "Removal of IPA CS replication agreement is" " deprecated with managed IPA" " replication topology", 1)