From 51425337d8ee3e6dc773b488f486ae7b753f51a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Panzar?= Date: Sun, 27 Sep 2020 20:25:33 +0200 Subject: [PATCH] Migrate to latest Play version - addresses #92 - cleans up load generator - fixes issues discovered by load test --- ui/libs/generator/src/lib/key.ts | 15 +++--- ui/libs/generator/src/lib/locale.ts | 4 ++ ui/libs/generator/src/lib/project/project.ts | 46 +++++++++++-------- ui/libs/generator/src/lib/user.ts | 2 +- .../src/lib/services/error-handler.ts | 7 ++- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/ui/libs/generator/src/lib/key.ts b/ui/libs/generator/src/lib/key.ts index cdc75efa..8fac2fd1 100644 --- a/ui/libs/generator/src/lib/key.ts +++ b/ui/libs/generator/src/lib/key.ts @@ -25,18 +25,17 @@ export const featureNames = [ 'dashboard', 'admin' ]; +export const parts = ['list', 'detail', 'find', 'search', 'main', 'header', 'footer']; export const keySuffixes = [ 'title', - 'header', 'description', - 'list', + 'text', + 'comment', 'get', 'create', 'update', 'delete', 'permission', - 'find', - 'search', 'sell', 'confirm', 'allow', @@ -44,9 +43,11 @@ export const keySuffixes = [ 'filter', 'clear' ]; -export const keyNames = cartesianProduct([featureNames, keySuffixes]).map((values: string[]) => - values.join('.') -); +export const keyNames = cartesianProduct([ + featureNames, + parts, + keySuffixes +]).map((values: string[]) => values.join('.')); export const createKey = ( injector: Injector, diff --git a/ui/libs/generator/src/lib/locale.ts b/ui/libs/generator/src/lib/locale.ts index bd7ef416..03e1c33a 100644 --- a/ui/libs/generator/src/lib/locale.ts +++ b/ui/libs/generator/src/lib/locale.ts @@ -130,6 +130,10 @@ export const deleteRandomLocale = (injector: Injector): Observable + payload.locales.length > 0 + ), concatMap( (payload: { user: User; accessToken: AccessToken; project: Project; locales: Locale[] }) => deleteLocale( diff --git a/ui/libs/generator/src/lib/project/project.ts b/ui/libs/generator/src/lib/project/project.ts index e6f90b55..4fd7f451 100644 --- a/ui/libs/generator/src/lib/project/project.ts +++ b/ui/libs/generator/src/lib/project/project.ts @@ -66,30 +66,32 @@ export const createRandomProject = (injector: Injector): Observable { return combineLatest( - _.sample(localeNames, Math.ceil(Math.random() * 12)).map((localeName: string) => - createLocale( - injector, - { - name: localeName, - projectId: payload.project.id - }, - payload.accessToken - ) - ) - ).pipe(map((locales: Locale[]) => ({ ...payload, locales }))); - }), - concatMap( - (payload: { user: User; project: Project; locales: Locale[]; accessToken: AccessToken }) => { - return combineLatest( - _.sample(keyNames, Math.ceil(Math.random() * 50)).map((keyName: string) => - createKey( + _.sample(localeNames, Math.ceil(Math.random() * localeNames.length)).map( + (localeName: string) => + createLocale( injector, { - name: keyName, + name: localeName, projectId: payload.project.id }, payload.accessToken ) + ) + ).pipe(map((locales: Locale[]) => ({ ...payload, locales }))); + }), + concatMap( + (payload: { user: User; project: Project; locales: Locale[]; accessToken: AccessToken }) => { + return combineLatest( + _.sample(keyNames, Math.ceil((Math.random() * keyNames.length) / 10)).map( + (keyName: string) => + createKey( + injector, + { + name: keyName, + projectId: payload.project.id + }, + payload.accessToken + ) ) ).pipe(map((keys: Key[]) => ({ ...payload, keys }))); } @@ -122,7 +124,9 @@ export const createRandomProject = (injector: Injector): Observable of({ message: errorMessage(err) })) + catchError((err: HttpErrorResponse) => + of({ message: `createRandomProject: ${errorMessage(err)}` }) + ) ); }; @@ -176,7 +180,9 @@ export const updateRandomProject = (injector: Injector): Observable ({ message: `${payload.user.name} updated project ${payload.project.name}` })), - catchError((err: HttpErrorResponse) => of({ message: errorMessage(err) })) + catchError((err: HttpErrorResponse) => + of({ message: `updateRandomProject: ${errorMessage(err)}` }) + ) ); }; diff --git a/ui/libs/generator/src/lib/user.ts b/ui/libs/generator/src/lib/user.ts index 5ac14ac4..403b5723 100644 --- a/ui/libs/generator/src/lib/user.ts +++ b/ui/libs/generator/src/lib/user.ts @@ -86,7 +86,7 @@ export const createRandomUser = (userService: UserService): Observable { - console.warn(errorTemplate(error, request)); + if ( + error.error?.error?.violations[0]?.message !== 'error.nameunique' && + error.error?.error?.violations[0]?.message !== 'Entry already exists (duplicate key)' + ) { + console.warn(errorTemplate(error, request)); + } return throwError(error); } }