Beispiel #1
0
 def _test_direct_get_suffix_hashes_fail(self, status_code):
     with mocked_http_conn(status_code):
         with self.assertRaises(DirectClientException) as cm:
             direct_client.direct_get_suffix_hashes(
                 self.node, self.part, ['a83', 'b52'])
     self.assertIn('REPLICATE', cm.exception.message)
     self.assertIn(quote('/%s/%s/a83-b52'
                         % (self.node['device'], self.part)),
                   cm.exception.message)
     self.assertIn(self.node['replication_ip'], cm.exception.message)
     self.assertIn(self.node['replication_port'], cm.exception.message)
     self.assertEqual(self.node['replication_ip'], cm.exception.http_host)
     self.assertEqual(self.node['replication_port'], cm.exception.http_port)
     self.assertEqual(self.node['device'], cm.exception.http_device)
     self.assertEqual(status_code, cm.exception.http_status)
Beispiel #2
0
 def test_direct_get_suffix_hashes(self):
     data = {'a83': 'c130a2c17ed45102aada0f4eee69494ff'}
     body = pickle.dumps(data)
     with mocked_http_conn(200, {}, body) as conn:
         resp = direct_client.direct_get_suffix_hashes(self.node,
                                                       self.part, ['a83'])
         self.assertEqual(conn.method, 'REPLICATE')
         self.assertEqual(conn.path, '/sda/0/a83')
         self.assertEqual(conn.host, '1.2.3.5')
         self.assertEqual(conn.port, '7000')
         self.assertEqual(data, resp)
Beispiel #3
0
 def _assert_consistent_suffix_hashes(self):
     opart, onodes = self.object_ring.get_nodes(
         self.account, self.container_name, self.object_name)
     name_hash = hash_path(
         self.account, self.container_name, self.object_name)
     results = []
     for node in onodes:
         results.append(
             (node,
              direct_get_suffix_hashes(node, opart, [name_hash[-3:]])))
     for (node, hashes) in results[1:]:
         self.assertEqual(results[0][1], hashes,
                          'Inconsistent suffix hashes found: %s' % results)
 def _assert_consistent_suffix_hashes(self):
     opart, onodes = self.object_ring.get_nodes(
         self.account, self.container_name, self.object_name)
     name_hash = hash_path(
         self.account, self.container_name, self.object_name)
     results = []
     for node in onodes:
         results.append(
             (node,
              direct_get_suffix_hashes(node, opart, [name_hash[-3:]])))
     for (node, hashes) in results[1:]:
         self.assertEqual(results[0][1], hashes,
                          'Inconsistent suffix hashes found: %s' % results)
Beispiel #5
0
def main():
    args = parser.parse_args()

    policy = POLICIES[args.policy_index]

    policy.load_ring('/etc/swift/')
    ring = policy.object_ring

    suffixes = args.suffix or []
    for node in ring.devs:
        if node is None:
            continue
        if args.device and node['device'] != args.device:
            continue
        data = direct_get_suffix_hashes(
            node,
            args.part,
            suffixes,
            headers={'x-backend-storage-policy-index': int(policy)})
        print node['ip'], node['port'], node['device']
        print data