def test_cluster_rpc_stop_proxy_request(self, mock_uuid): mock_uuid.uuid4.return_value = 'test-uuid' rpc = swift_utils.SwiftProxyClusterRPC() rq = rpc.stop_proxy_request(peers_only=True) self.assertEqual( { 'trigger': 'test-uuid', 'broker-token': None, 'broker-timestamp': None, 'builder-broker': '1.2.3.4', 'peers-only': 1, 'leader-changed-notification': None, 'resync-request': None, 'stop-proxy-service': 'test-uuid', 'stop-proxy-service-ack': None, 'sync-only-builders': None }, rq) rq = rpc.stop_proxy_request() self.assertEqual( { 'trigger': 'test-uuid', 'broker-token': None, 'broker-timestamp': None, 'builder-broker': '1.2.3.4', 'peers-only': None, 'leader-changed-notification': None, 'resync-request': None, 'stop-proxy-service': 'test-uuid', 'stop-proxy-service-ack': None, 'sync-only-builders': None }, rq) template_keys = set(rpc.template()) self.assertTrue(set(rq.keys()).issubset(template_keys))
def test_cluster_rpc_notify_leader_changed(self, mock_uuid): mock_uuid.uuid4.return_value = 'e4b67426-6cc0-4aa3-829d-227999cd0a75' rpc = swift_utils.SwiftProxyClusterRPC() rq = rpc.notify_leader_changed('token1') self.assertEqual({'trigger': 'e4b67426-6cc0-4aa3-829d-227999cd0a75', 'broker-token': None, 'builder-broker': None, 'broker-timestamp': None, 'peers-only': None, 'leader-changed-notification': 'token1', 'stop-proxy-service': None, 'stop-proxy-service-ack': None, 'resync-request': None, 'sync-only-builders': None}, rq) template_keys = set(rpc.template().keys()) self.assertTrue(set(rq.keys()).issubset(template_keys))
def test_cluster_rpc_sync_request(self, mock_uuid, mock_time): mock_time.time = mock.Mock(return_value=float(1.234)) mock_uuid.uuid4.return_value = 'token2' rpc = swift_utils.SwiftProxyClusterRPC() rq = rpc.sync_rings_request('token1') self.assertEqual({'trigger': 'token2', 'broker-token': 'token1', 'broker-timestamp': '1.234000', 'builder-broker': '1.2.3.4', 'peers-only': None, 'leader-changed-notification': None, 'resync-request': None, 'stop-proxy-service': None, 'stop-proxy-service-ack': None, 'sync-only-builders': None}, rq) template_keys = set(rpc.template()) self.assertTrue(set(rq.keys()).issubset(template_keys))