Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8424 Fix KNL job configurations #5345

Merged
merged 24 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0a72ea4
Move defaultMirkoOrmOptions to shared, to avoid implicit importing th…
CeEv Nov 18, 2024
35afb4b
Fix idp-console.module configs with dependencies
CeEv Nov 18, 2024
36987c5
Cleanup imports for idp
CeEv Nov 19, 2024
9edd16c
Improve test setup for idp uc
CeEv Nov 19, 2024
eac8ced
Change deletion-console configuration setup. Cleanup code to make con…
CeEv Nov 19, 2024
14bdf8a
Change check and add additional test for it.
CeEv Nov 19, 2024
90e256e
Merge branch 'main' into BC-8424-fix-knl-job-configurations
CeEv Nov 19, 2024
d211706
Remove module facade exports, they are not needed.
CeEv Nov 19, 2024
450664a
Move files to match with new project folder structures.
CeEv Nov 25, 2024
1236209
Merge branch 'main' into BC-8424-fix-knl-job-configurations
CeEv Nov 25, 2024
d4185ee
Change console api test that they based on the production module. Thi…
CeEv Nov 25, 2024
10bdd96
Merge branch 'BC-8424-fix-knl-job-configurations' of https://github.c…
CeEv Nov 25, 2024
c1c7027
Change code style
CeEv Nov 27, 2024
aacf4c2
Merge branch 'main' into BC-8424-fix-knl-job-configurations
CeEv Nov 27, 2024
4d01342
naming
CeEv Nov 27, 2024
7e70c99
change note similar to existings
CeEv Nov 27, 2024
da20b98
Fix todo
CeEv Nov 27, 2024
85a9a31
fix todo
CeEv Nov 27, 2024
216ad91
remove todo
CeEv Nov 27, 2024
858c522
Revert "fix todo"
CeEv Nov 27, 2024
7d139b4
Remove todo
CeEv Nov 27, 2024
a2cd647
Merge branch 'main' into BC-8424-fix-knl-job-configurations
CeEv Nov 27, 2024
9e9f971
remove comments
CeEv Nov 27, 2024
0a9e6ac
Merge branch 'BC-8424-fix-knl-job-configurations' of https://github.c…
CeEv Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/apps/deletion-console.app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { DeletionConsoleModule } from '@src/modules/deletion-console';
import { DeletionConsoleModule } from '@modules/deletion-console/deletion-console.app.module';
import { BootstrapConsole } from 'nestjs-console';

async function run() {
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/apps/idp-console.app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { IdpConsoleModule } from '@modules/idp-console';
import { IdpConsoleModule } from '@modules/idp-console/idp-console.app.module';
import { BootstrapConsole } from 'nestjs-console';

async function run() {
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/infra/console/console-writer.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ConsoleWriterConfig {}
3 changes: 2 additions & 1 deletion apps/server/src/infra/console/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './console-writer';
export { ConsoleWriterModule, ConsoleWriterService } from './console-writer';
export { ConsoleWriterConfig } from './console-writer.config';
9 changes: 8 additions & 1 deletion apps/server/src/infra/rabbitmq/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
export * from './error.mapper';
export * from './exchange';
export * from './rabbitmq.config';
export {
RabbitMqConfig,
FilesPreviewExchange,
FilesStorageExchange,
MailSendExchange,
AntivirusExchange,
RabbitMqURI,
} from './rabbitmq.config';
export * from './rabbitmq.module';
export * from './rpc-message';
export * from './rpc-message-producer';
4 changes: 4 additions & 0 deletions apps/server/src/infra/rabbitmq/rabbitmq.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Configuration } from '@hpi-schul-cloud/commons/lib';

// should be move to config interface and added reading on places that use the module
export const FilesPreviewExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
export const FilesStorageExchange = Configuration.get('FILES_STORAGE__EXCHANGE') as string;
export const MailSendExchange = Configuration.get('MAIL_SEND_EXCHANGE') as string;
export const AntivirusExchange = Configuration.get('ANTIVIRUS_EXCHANGE') as string;
export const RabbitMqURI = Configuration.get('RABBITMQ_URI') as string;

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RabbitMqConfig {}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AuthGuardModule, AuthGuardOptions } from '@infra/auth-guard';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { defaultMikroOrmOptions } from '@modules/server';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { AuthorizationModule } from '../authorization';
import { config } from './board-collaboration.config';
import { BoardWsApiModule } from './board-ws-api.module';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defaultMikroOrmOptions, serverConfig } from '@modules/server';
import { serverConfig } from '@modules/server';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ALL_ENTITIES } from '@shared/domain/entity';
Expand All @@ -7,6 +7,7 @@ import { CoreModule } from '@src/core';
import { AuthGuardModule, AuthGuardOptions } from '@src/infra/auth-guard';
import { MongoMemoryDatabaseModule } from '@src/infra/database';
import { RabbitMQWrapperTestModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { AuthenticationApiModule } from '../authentication/authentication-api.module';
import { AuthorizationModule } from '../authorization';
import { config as boardCollaborationConfig } from './board-collaboration.config';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '../server';
import { defaultMikroOrmOptions } from '@shared/common';
import { BoardClientModule } from './common-cartridge-client/board-client';
import { CoursesClientModule } from './common-cartridge-client/course-client';
import { CommonCartridgeExportService } from './service/common-cartridge-export.service';
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,22 @@ import { axiosResponseFactory } from '@shared/testing';
import { DeletionRequestInputBuilder, DeletionRequestOutputBuilder } from '.';
import { DeletionRequestOutput } from './interface';
import { DeletionClient } from './deletion.client';
import { DeletionConsoleConfig } from '../deletion.config';

describe(DeletionClient.name, () => {
let module: TestingModule;
let client: DeletionClient;
let configService: DeepMocked<ConfigService>;
let httpService: DeepMocked<HttpService>;

beforeEach(async () => {
module = await Test.createTestingModule({
providers: [
DeletionClient,
{
provide: ConfigService,
useValue: createMock<ConfigService>({
get: jest.fn((key: string) => {
if (key === 'ADMIN_API_CLIENT_BASE_URL') {
return 'http://localhost:4030';
}

// Default is for the Admin APIs API Key.
return '6b3df003-61e9-467c-9e6b-579634801896';
}),
}),
useValue: createMock<ConfigService<DeletionConsoleConfig, true>>(),
},
DeletionClient,
{
provide: HttpService,
useValue: createMock<HttpService>(),
Expand All @@ -39,6 +32,7 @@ describe(DeletionClient.name, () => {
}).compile();

client = module.get(DeletionClient);
configService = module.get(ConfigService);
httpService = module.get(HttpService);
});

Expand All @@ -50,9 +44,17 @@ describe(DeletionClient.name, () => {
await module.close();
});

const setupConfig = () => {
// Please take a look that the order is correct if the code order is changed
configService.get
.mockReturnValueOnce('652559c2-93da-42ad-94e1-640e3afbaca0')
.mockReturnValueOnce('http://api-admin:4030');
};

describe('queueDeletionRequest', () => {
describe('when sending the HTTP request failed', () => {
const setup = () => {
setupConfig();
const input = DeletionRequestInputBuilder.build('user', '652f1625e9bc1a13bdaae48b');

const error = new Error('unknown error');
Expand All @@ -70,6 +72,7 @@ describe(DeletionClient.name, () => {

describe('when received valid response with expected HTTP status code', () => {
const setup = () => {
setupConfig();
const input = DeletionRequestInputBuilder.build('user', '652f1625e9bc1a13bdaae48b');

const output: DeletionRequestOutput = DeletionRequestOutputBuilder.build(
Expand Down Expand Up @@ -98,6 +101,7 @@ describe(DeletionClient.name, () => {

describe('when received invalid HTTP status code in a response', () => {
const setup = () => {
setupConfig();
const input = DeletionRequestInputBuilder.build('user', '652f1625e9bc1a13bdaae48b');

const output: DeletionRequestOutput = DeletionRequestOutputBuilder.build('', new Date());
Expand All @@ -121,6 +125,7 @@ describe(DeletionClient.name, () => {

describe('when received no requestId in a response', () => {
const setup = () => {
setupConfig();
const input = DeletionRequestInputBuilder.build('user', '652f1625e9bc1a13bdaae48b');

const output: DeletionRequestOutput = DeletionRequestOutputBuilder.build(
Expand All @@ -147,6 +152,7 @@ describe(DeletionClient.name, () => {

describe('when received no deletionPlannedAt in a response', () => {
const setup = () => {
setupConfig();
const input = DeletionRequestInputBuilder.build('user', '652f1625e9bc1a13bdaae48b');

const response: AxiosResponse<DeletionRequestOutput> = axiosResponseFactory.build({
Expand All @@ -172,6 +178,7 @@ describe(DeletionClient.name, () => {
describe('executeDeletions', () => {
describe('when sending the HTTP request failed', () => {
const setup = () => {
setupConfig();
const error = new Error('unknown error');
httpService.post.mockReturnValueOnce(throwError(() => error));
};
Expand All @@ -185,6 +192,7 @@ describe(DeletionClient.name, () => {

describe('when received valid response with expected HTTP status code', () => {
const setup = () => {
setupConfig();
const limit = 10;

const response: AxiosResponse<DeletionRequestOutput> = axiosResponseFactory.build({
Expand All @@ -203,8 +211,31 @@ describe(DeletionClient.name, () => {
});
});

describe('when pass invalid limit', () => {
const setup = () => {
setupConfig();
const limit = true;

const response: AxiosResponse<DeletionRequestOutput> = axiosResponseFactory.build({
status: 204,
});

httpService.post.mockReturnValueOnce(of(response));

return { limit };
};

it('should ignore limit and use default headers', async () => {
const { limit } = setup();

// @ts-expect-error test case
await expect(client.executeDeletions(limit)).resolves.not.toThrow();
});
});

describe('when received invalid HTTP status code in a response', () => {
const setup = () => {
setupConfig();
const response: AxiosResponse<DeletionRequestOutput> = axiosResponseFactory.build({
status: 200,
});
Expand Down
Loading
Loading