def __init__(self, conf): super(DciControlServer, self).__init__(__name__) self.config.update(conf) self.url_map.strict_slashes = False self.engine = dci_config.get_engine(conf) self.es_engine = es_engine.DCIESEngine(conf) self.sender = self._get_zmq_sender(conf['ZMQ_CONN'])
def __init__(self, conf, elastic_engine=None): super(DciControlServer, self).__init__(__name__) self.config.update(conf) self.url_map.strict_slashes = False self.engine = dci_config.get_engine(conf) self.es_engine = elastic_engine if not self.es_engine: self.es_engine = es_engine.DCIESEngine(es_host=conf['ES_HOST'], es_port=conf['ES_PORT']) self.sender = self._get_zmq_sender(conf['ZMQ_CONN'])
def es_engine(request): el_engine = elastic_engine.DCIESEngine(es_host=utils.conf['ES_HOST'], es_port=utils.conf['ES_PORT'], index='dci', timeout=60) def fin(): el_engine.cleanup() request.addfinalizer(fin) return el_engine
def file_job_user_id(user, job_user_id, team_user_id): with mock.patch(SWIFT, spec=Swift) as mock_swift: mockito = mock.MagicMock() head_result = { 'etag': dci_utils.gen_etag(), 'content-type': "stream", 'content-length': 1 } mockito.head.return_value = head_result mock_swift.return_value = mockito headers = {'DCI-JOB-ID': job_user_id, 'DCI-NAME': 'name'} file = user.post('/api/v1/files', headers=headers, data='foobar').data headers['team_id'] = team_user_id headers['id'] = file['file']['id'] conn = es_engine.DCIESEngine(utils.conf) conn.index(headers) return file['file']['id']
def es_clean(request): conn = es_engine.DCIESEngine(utils.conf) conn.cleanup()
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from dci import dci_config from dci.elasticsearch import engine from tests import utils conf = dci_config.generate_conf() es_engine = engine.DCIESEngine(es_host=conf['ES_HOST'], es_port=conf['ES_PORT'], index='dci', timeout=60) def test_essync_add_files(user, admin, jobstate_user_id): for i in range(5): utils.post_file(user, jobstate_user_id, utils.FileDesc('kikoolol', 'content')) f_events = admin.get('/api/v1/files_events/0').data assert len(f_events['files']) == 5 env = { 'DCI_CS_URL': 'http://127.0.0.1:5000', 'DCI_LOGIN': '******', 'DCI_PASSWORD': '******' }