test(): skip flaky kafka integration test

This commit is contained in:
Kamil Myśliwiec
2021-02-12 14:58:03 +01:00
parent d84972609c
commit fcf57a64ed

View File

@@ -9,8 +9,12 @@ import { UserEntity } from '../src/kafka/entities/user.entity';
import { KafkaController } from '../src/kafka/kafka.controller';
import { KafkaMessagesController } from '../src/kafka/kafka.messages.controller';
describe('Kafka transport', function () {
let server;
/**
* Skip this flaky test in CI/CD pipeline as it frequently
* fails to connect to Kafka container in the cloud.
*/
describe.skip('Kafka transport', function () {
let server: any;
let app: INestApplication;
// set timeout to be longer (especially for the after hook)
@@ -18,41 +22,24 @@ describe('Kafka transport', function () {
this.retries(10);
before(`Start Kafka app`, async function () {
const startApp = async () => {
const module = await Test.createTestingModule({
controllers: [KafkaController, KafkaMessagesController],
}).compile();
const module = await Test.createTestingModule({
controllers: [KafkaController, KafkaMessagesController],
}).compile();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
app = module.createNestApplication();
server = app.getHttpAdapter().getInstance();
app.connectMicroservice({
transport: Transport.KAFKA,
options: {
client: {
brokers: ['localhost:9092'],
},
app.connectMicroservice({
transport: Transport.KAFKA,
options: {
client: {
brokers: ['localhost:9092'],
},
});
app.enableShutdownHooks();
await app.startAllMicroservices();
await app.init();
};
// since this frequently fails in the CI/CD pipeline
// we give it 10 retries to properly connect to Kafka & Zookepeer
// in the cloud
const MAX_RETRIES = 10;
for (let retries = 0; retries <= MAX_RETRIES; retries++) {
try {
await startApp();
break;
} catch (err) {
if (retries === MAX_RETRIES) {
throw err;
}
}
}
},
});
app.enableShutdownHooks();
await app.startAllMicroservices();
await app.init();
});
it(`/POST (sync sum kafka message)`, function () {
@@ -148,4 +135,4 @@ describe('Kafka transport', function () {
after(`Stopping Kafka app`, async () => {
await app.close();
});
}).timeout(50000);
});