Skip to content
Snippets Groups Projects
Commit a6afef4b authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'fix/cicd-timeout-on-search' into 'V2.0'

fix: elastic unit test

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server!147
parents 962b2b8f 641e4849
No related branches found
No related tags found
4 merge requests!247V2.1.0,!242V2.0,!147fix: elastic unit test,!127V2.0
stages:
- quality
- test
- quality
- build
- deploy
......@@ -8,9 +8,6 @@ default:
services:
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09-dind
alias: docker
- name: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/elasticsearch:7.16.2
alias: elasticsearch
command: ['bin/elasticsearch', '-Expack.security.enabled=false', '-Ediscovery.type=single-node']
variables:
DEPENDENCY_PROXY: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/
......
......@@ -113,22 +113,6 @@ services:
ports:
- ${ELASTICSEARCH_PORT}:9200
kib01:
image: docker.elastic.co/kibana/kibana:7.6.1
restart: unless-stopped
container_name: resin-kib
ports:
- ${KIBANA_PORT}:5601
environment:
ELASTICSEARCH_URL: http://es01:9200
ELASTICSEARCH_HOSTS: '["http://es01:9200"]'
ELASTICSEARCH_USERNAME: elastic
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD}
depends_on:
- es01
networks:
- elastic
volumes:
db-ram:
driver: local
......
......@@ -23,35 +23,44 @@ describe('StructuresSearchService', () => {
service = module.get<StructuresSearchService>(StructuresSearchService);
service['index'] = 'structures-unit-test';
});
it('should be defined', () => {
expect(service).toBeDefined();
});
it('should create index', async () => {
await service.dropIndex();
const res = await service.createStructureIndex();
expect(res).toBeTruthy();
});
await service.createStructureIndex();
it('should index structures', async () => {
// init str
const structuresForSearchService = new StructuresForSearchServiceMock();
const structures = structuresForSearchService.findAll();
const res = await Promise.all(
await Promise.all(
structures.map((structure: any) => {
service.indexStructure(structure);
})
);
expect(res).toBeTruthy();
// wait for the new structures to be indexed before search
await service.refreshIndexStructure();
// but we still need to wait the refresh to be done
await new Promise((r) => setTimeout(r, 2000));
}, 10000);
it('should be defined', () => {
expect(service).toBeDefined();
});
// it('should index structures', async () => {
// const structuresForSearchService = new StructuresForSearchServiceMock();
// const structures = structuresForSearchService.findAll();
// const res = await Promise.all(
// structures.map((structure: any) => {
// service.indexStructure(structure);
// })
// );
// expect(res).toBeTruthy();
// // wait for the new structures to be indexed before search
// await service.refreshIndexStructure();
// // but we still need to wait the refresh to be done
// await new Promise((r) => setTimeout(r, 2000));
// });
it('should find maisons de la métropole', async () => {
const res = await service.search('maison de la');
//Logger.log(JSON.stringify(res));
......
......@@ -47,13 +47,22 @@ describe('EmployerSearchService Search cases', () => {
await service.dropIndex();
await service.createEmployerIndex();
await Promise.all(employers.map((employer: any) => service.indexEmployer(employer)));
await new Promise((r) => setTimeout(r, 1500));
});
it('should be defined', () => {
// wait for the new structures to be indexed before search
await service.refreshIndexStructure();
await new Promise((r) => setTimeout(r, 2000));
}, 10000);
it('should be defined', async () => {
// await new Promise((r) => setTimeout(r, 9000));
expect(service).toBeDefined();
});
// it('should index structures', async () => {
// // but we still need to wait the refresh to be done
// await new Promise((r) => setTimeout(r, 2000));
// }, 10000);
it('should find CARSAT', async () => {
const res = await service.search('CARSAT');
expect(res[0].name).toBe('CARSAT');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment