MyGit

scottweaver/testcontainers-for-zio

Fork: 21 Star: 48 (更新于 2024-11-26 09:54:20)

license: 暂无

Language: Scala .

最后发布版本: v0.10.0 ( 2023-02-15 11:13:52)

GitHub网址

Testcontainers for ZIO

main

Provides idiomatic, easy-to-use ZLayers for Testcontainers-scala.

Testcontainers Best-Practices

SBT Settings

  • Make sure your test configuration has the following settings Test / fork := true. Without this the Docker container created by the test will NOT be cleaned up until you exit SBT/the JVM process. This could quickly run your machine out of resources as you will end up with a ton of orphaned containers running.
  • Use provideLayerShared({container}.live) on your suite so that each test case isn't spinning up and down the container.

Logging

The testcontainer runtime can get pretty noisy when it comes to logging. To reduce this noise in your test cases, I recommend creating (or updating) the src/test/resources/logback-test.xml file in your project based on the following sample:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} %msg%n</Pattern>
      </layout>
    </encoder>
  </appender>


  <root level="WARN">
    <appender-ref ref="STDOUT" />
  </root>

  <logger name="org.testcontainers" level="WARN" />
  <logger name="com.github.dockerjava" level="WARN" />
  <logger name="ch.qos.logback" level="WARN" />
  <!-- Only relevant if you are using the db migration aspect -->
  <logger name="org.flywaydb" level="WARN" />
</configuration>

Cassandra

Release Artifacts

Provides a managed ZLayer that starts and stops a com.dimafeng.testcontainers.CassandraContainer as well as also providing a managed com.datastax.oss.driver.api.core.CqlSession.

ZIO 1.x

libraryDependencies += "io.github.scottweaver" %% "zio-testcontainers-cassandra" % "0.10.0"

ZIO 2.x

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-testcontainers-cassandra" % "0.10.0"

See test cases for example usage.

MySQL

Release Artifacts

Provides a managed ZLayer that starts and stops a com.dimafeng.testcontainers.MySQLTestContainer as well as also providing a managed java.sql.Connection and a javax.sql.DataSource.

ZIO 1.x

libraryDependencies += "io.github.scottweaver" %% "zio-testcontainers-mysql" % "0.10.0"

ZIO 2.x

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-testcontainers-mysql" % "0.10.0"

See test cases for example usage.

PostgreSQL

Release Artifacts

Provides a managed ZLayer that starts and stops a com.dimafeng.testcontainers.PostgreSQLContainer as well as also providing a managed java.sql.Connection and a javax.sql.DataSource.

ZIO 1.x

libraryDependencies += "io.github.scottweaver" %% "zio-testcontainers-postgresql" % "0.10.0"

ZIO 2.x

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-testcontainers-postgresql" % "0.10.0"

See test cases for example usage.

Kafka

Release Artifacts

Provides a managed ZLayer that starts and stops a com.dimafeng.testcontainers.KafkaContainer.

You also have easy access to:

  • zio.kafka.consumer.ConsumerSettings via ZKafkaContainer.defaultConsumerSettings.
  • zio.kafka.consumer.ProducerSettings via ZKafkaContainer.defaultProducerSettings.

You can use these to create a zio.kafka.consumer.Consumer and/or zio.kafka.producer.Producer that can be used to interact with the Kafka container instance.

ZIO 1.x

libraryDependencies += "io.github.scottweaver" %% "zio-testcontainers-kafka" % "0.10.0"

ZIO 2.x

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-testcontainers-kafka" % "0.10.0"

See test cases for example usage.

Database Migrations Aspect

Release Artifacts

Not really a test container, useful none the less.

The io.github.scottweaver.zio.aspect.DatabaseMigrationsAspect provides a ZIO TestAspect for running database migrations via Flyway. It seamlessly integrates with the ZMySQLContainer or ZPostrgeSQLContainer by using the io.github.scottweaver.zio.models.JdbcInfo provided by ZMySQLContainer.live or ZPostrgeSQLContainer.live to run your migrations.

If you are not using ZMySQLContainer or ZPostrgeSQLContainer you can just manually provide an appropriate JdbcInfo as a ZLayer to your tests that are using the DbMigrationAspect.

ZIO 1.X

libraryDependencies += "io.github.scottweaver" %% "zio-db-migration-aspect" % "0.10.0"

ZIO 2.X

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-db-migration-aspect" % "0.10.0"

Liquibase Aspect

Release Artifacts

An alternative to the Flyway-based DbMigrationsAspect that uses Liquibase instead.

The io.github.scottweaver.zio.aspect.LiquibaseAspect provides a ZIO TestAspect for running database migrations via Liquibase. It seamlessly integrates with the ZMySQLContainer or ZPostrgeSQLContainer by using the io.github.scottweaver.zio.models.JdbcInfo provided by ZMySQLContainer.live or ZPostrgeSQLContainer.live to run your Changelog migrations.

If you are not using ZMySQLContainer or ZPostgreSQLContainer you can just manually provide an appropriate JdbcInfo as a ZLayer to your tests that are using the LiquibaseAspect.

ZIO 2.X

libraryDependencies += "io.github.scottweaver" %% "zio-2.0-liquibase-aspect" % "0.10.0"

Cassandra Migrations Aspect

Release Artifacts

Not really a test container, useful none the less.

The io.github.scottweaver.zio.aspect.CassandraMigrationsAspect provides a ZIO TestAspect for running database migrations via Cassandra Schema Migration. It seemlessly integrates with the ZCassandraContainer by using the com.datastax.oss.driver.api.core.CqlSession provided by ZCassandraContainer.live to run your migrations.

If you are not using ZCassandraContainer you can just manually provide an appropriate com.datastax.oss.driver.api.core.CqlSession as a ZLayer to your tests that are using the CassandraMigrationAspect.

ZIO 1.X

libraryDependencies += "io.github.scottweaver" %% "zio-cassandra-migration-aspect" % "0.10.0"

ZIO 2.X

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-cassandra-migration-aspect" % "0.10.0"

Solr

Release Artifacts

Provides a managed ZLayer that starts and stops a com.dimafeng.testcontainers.SolrContainer.

You can use the container host, solrPort to access the web interface. The settings can be customized with schema/solrconfig.xml urls to create a collection.

ZIO 2.x

libraryDependencies += "io.github.scottweaver" %% "zio-2-0-testcontainers-solr" % "0.10.0"

References

最近版本更新:(数据更新于 2024-09-14 00:34:46)

2023-02-15 11:13:52 v0.10.0

2022-10-13 00:04:10 v0.9.0

2022-07-14 05:22:55 v0.8.0

2022-07-06 23:51:37 v0.7.0

2022-05-27 05:25:56 v0.6.0

2022-05-15 01:00:52 v0.5.0

2022-03-03 04:49:17 v0.4.1

2022-03-03 04:47:58 v0.4.0

2022-02-22 09:45:57 v0.3.0

2021-11-27 04:15:40 v0.2.0

scottweaver/testcontainers-for-zio同语言 Scala最近更新仓库

2024-10-05 03:06:12 delta-io/delta-sharing

2024-09-25 11:49:48 enso-org/enso

2024-09-05 00:48:36 delta-io/delta

2024-08-30 10:16:51 microsoft/SynapseML

2024-05-08 03:46:22 twitter/finagle

2024-03-16 01:53:23 databrickslabs/smolder