Getting an error while trying to run Temporal testcontainer

hi,
I am getting the following error while trying to run the Temporal testcontainer in order to run the unit tests. tried many options in the docker-compose-temporal.yaml and test\application.yml.

this is a blocker for proceeding with the development.

please advice.

2022-05-23T14:14:41.072+0000 [DEBUG] [TestEventLogger]     14:14:41.072 [Test worker] WARN  o.s.b.w.r.c.GenericReactiveWebApplicationContext  - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ai.applica.spring.boot.starter.temporal.processors.WorkflowAnnotationBeanPostProcessor': Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultWorkerFactory' defined in ai.applica.spring.boot.starter.temporal.config.TemporalBootstrapConfiguration: Unsatisfied dependency expressed through method 'defaultWorkerFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultClient' defined in ai.applica.spring.boot.starter.temporal.config.TemporalBootstrapConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.temporal.client.WorkflowClient]: Factory method 'defaultClient' threw exception; nested exception is io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason

Thanks,
Shai

trying to run the Temporal testcontainer

are you configuring your tests to use external service and your own test workers?
Looks as your test config has issues creating WorkerFactory, most likely because your WorkflowClient producer is failing (cannot connect to test container frontend service). Do you have a test config? Check your test server frontend service health (tctl cl h). Does it have tls set up?

For unit testing you should be able to use internal TestWorkflowEnvironment. SDK also provides utils for JUnit4/5 as well, see many tests in samples repo.

hi tihomir,
thanks for your reply.

the problem was solved by replacing Cassandra with Mysql on the temporal test-container. the failure was caused due to lack of resources, apparently.

version: "3.5"
services:
  mysql:
    environment:
      - MYSQL_ROOT_PASSWORD=root
    image: mysql:5.7
    networks:
      - temporal-network
    ports:
      - 3306:3306
  temporal:
    depends_on:
      - mysql

Thanks,
Shai

1 Like