Ejemplo n.º 1
0
    def test_GETorHEAD_base(self):
        base = Controller(self.app)
        req = Request.blank('/v1/a/c/o/with/slashes')
        with patch('osd.proxyService.controllers.base.'
                   'http_connect', fake_http_connect(200)):
            resp = base.GETorHEAD_base(req, 'object', FakeObjectRing(''), [{'ip': '1.2.3', 'port': '0000'}], \
                                        'fs0', 'd0', '/a/c/o/with/slashes', 5.0, 0)
        self.assertTrue('swift.object/a/c/o/with/slashes' in resp.environ)
        self.assertEqual(
            resp.environ['swift.object/a/c/o/with/slashes']['status'], 200)
        req = Request.blank('/v1/a/c/o')
        with patch('osd.proxyService.controllers.base.'
                   'http_connect', fake_http_connect(200)):
            resp = base.GETorHEAD_base(req, 'object', FakeObjectRing(''), [{'ip': '1.2.3', 'port': '0000'}], \
                                        'fs0', 'd0', '/a/c/o', 5.0, 0)
        self.assertTrue('swift.object/a/c/o' in resp.environ)
        self.assertEqual(resp.environ['swift.object/a/c/o']['status'], 200)
        req = Request.blank('/v1/a/c')
        with patch('osd.proxyService.controllers.base.'
                   'http_connect', fake_http_connect(200)):
            resp = base.GETorHEAD_base(req, 'container', FakeContainerRing(''), [{'ip': '1.2.3', 'port': '0000'}], \
                                        'fs0', 'd0', '/a/c', 5.0, 0)
        self.assertTrue('swift.container/a/c' in resp.environ)
        self.assertEqual(resp.environ['swift.container/a/c']['status'], 200)

        req = Request.blank('/v1/a')
        with patch('osd.proxyService.controllers.base.'
                   'http_connect', fake_http_connect(200)):
            resp = base.GETorHEAD_base(req, 'account', FakeAccountRing(''), [{'ip': '1.2.3', 'port': '0000'}], \
                                        'fs0', 'd0', '/a', 5.0, 0)
        self.assertTrue('swift.account/a' in resp.environ)
        self.assertEqual(resp.environ['swift.account/a']['status'], 200)
Ejemplo n.º 2
0
 def test_make_requests(self):
     req = Request.blank('/v1/a/c/o') 
     with patch('osd.proxyService.controllers.base.'
                'http_connect', side_effect=Exception):
         resp = self.base.make_requests(req, FakeObjectRing(''), [{'ip': '1.2.3.4', 'port': '0000'}], 'fs1', \
             'd1', 'HEAD', '/a/c/o', {'test': 'value'})
         self.assertEqual(resp.status, '503 Internal Server Error')
     with patch('osd.proxyService.controllers.base.'
                'http_connect', fake_http_connect(200)):
         resp = self.base.make_requests(req, FakeObjectRing(''), [{'ip': '1.2.3.4', 'port': '0000'}], 'fs1', \
             'd1', 'HEAD', '/a/c/o', {'test': 'value'})
         self.assertEqual(resp.status.split()[0], '200')
Ejemplo n.º 3
0
 def setUp(self):
     self.app = proxy_server.Application(None, FakeMemcache(),
                                         account_ring=FakeAccountRing(''),
                                         container_ring=FakeContainerRing(''),
                                         object_ring=FakeObjectRing(''),
                                         logger=FakeLogger())
     self.base = Controller(self.app)
Ejemplo n.º 4
0
 def setUp(self):
     logger = debug_logger('proxy-server')
     logger.thread_locals = ('txn1', '127.0.0.2')
     self.app = proxy_server.Application(
         None,
         FakeMemcache(),
         account_ring=FakeAccountRing(''),
         container_ring=FakeContainerRing(''),
         object_ring=FakeObjectRing(''),
         logger=logger)
     self.controller = proxy_server.ObjectController(
         self.app, 'a', 'c', 'o')
     self.controller.container_info = mock.MagicMock(
         return_value={
             'node': [
                 {
                     'ip': '127.0.0.1',
                     'port': '1'
                 },
             ],
             'filesystem': 'fs0',
             'directory': 'd0',
             'sync_key': None,
             'write_acl': None,
             'versions': None,
             'read_acl': None
         })