Skip to content

Commit

Permalink
change wait strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
slemke committed Apr 22, 2024
1 parent 601bdbb commit 970c7d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/container/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class KeycloakContainer extends GenericContainer {

public override async start(): Promise<StartedKeycloakContainer> {
this.withExposedPorts(...this.ports);
this.withWaitStrategy(Wait.forHttp('/realms/master', this.defaultPort));
this.withWaitStrategy(Wait.forLogMessage(/(.*)Running the server in development mode(.*)/));
this.withCommand(this.commandsBuilder.build());
this.withEnvironment(this.environmentBuilder.build());
return new StartedKeycloakContainer(await super.start(), this.adminUser);
Expand Down
13 changes: 1 addition & 12 deletions test/container/container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ describe.sequential('Container', () => {

it('should be able to use admin client', async () => {
const startedContainer = await initCustomKeycloakContainer().start();
const stream = await startedContainer.logs();
stream
.on("data", line => console.log(line))
.on("err", line => console.error(line))
.on("end", () => console.log("Stream closed"));

const client = await startedContainer.getAdminClient();
expect(client.realmName).toBe('master');
await startedContainer.stop({ timeout: 10000 });
Expand All @@ -34,21 +30,14 @@ describe.sequential('Container', () => {
username: 'test',
password: 'test'
}).start();
const stream = await startedContainer.logs();
stream
.on("data", line => console.log(line))
.on("err", line => console.error(line))
.on("end", () => console.log("Stream closed"));

await new Promise((resolve) => setTimeout(resolve, 2000));
const client = await startedContainer.getAdminClient();
expect(client.realmName).toBe('master');
await startedContainer.stop({ timeout: 10000 });
});

const initCustomKeycloakContainer = (): KeycloakContainer => {
return new KeycloakContainer()
.withWaitStrategy(Wait.forLogMessage(/(.*)Running the server in development mode(.*)/, 5))
.withHostname('keycloak')
.withHealth()
.withFeatures([
Expand Down

0 comments on commit 970c7d9

Please sign in to comment.