Class HanaContainer.Builder

java.lang.Object
io.ebean.test.containers.HanaContainer.Builder
All Implemented Interfaces:
ContainerBuilder<HanaContainer,HanaContainer.Builder>, ContainerBuilderDb<HanaContainer,HanaContainer.Builder>
Enclosing class:
HanaContainer

public static class HanaContainer.Builder extends Object
SAP HANA configuration.

For more information about the HANA docker configuration see the tutorial Installing SAP HANA, express edition with Docker

  • Field Details

    • characterSet

      protected String characterSet
      The character set to use.
    • collation

      protected String collation
      The collation to use.
    • platform

      protected final String platform
      The database platform.

      Expected to be one of 'postgres','mysql', 'oracle' or 'sqlserver'.

    • containerName

      protected String containerName
      Container name.
    • host

      protected String host
      The host name. When running in Docker this is often set to 172.17.0.1invalid input: '<'/code.
    • port

      protected int port
      The exposed port.
    • internalPort

      protected int internalPort
      The internal port.
    • adminPort

      protected int adminPort
      The exposed port.
    • adminInternalPort

      protected int adminInternalPort
      The internal port.
    • mirror

      protected String mirror
      Define a mirror for images to use with CI builds.
    • image

      protected String image
      Image name.
    • startMode

      protected StartMode startMode
      The mode used when starting (create, dropCreate, container [only]).
    • shutdownMode

      protected StopMode shutdownMode
      By default, via JVM shutdown hook stop and remove the container unless there is a ~/.ebean/ignore-docker-shutdown marker file.
    • maxReadyAttempts

      protected int maxReadyAttempts
      Maximum number of attempts to find the 'database ready to accept connections' log message in the container.

      100 attempts equates to 10 seconds.

    • docker

      protected String docker
      Docker command.
    • version

      protected final String version
  • Method Details

    • extraProperties

      protected void extraProperties(Properties properties)
      Override to configure extra properties.
    • buildJdbcUrl

      protected String buildJdbcUrl()
      Return the JDBC URL for connecting to the database
    • build

      public HanaContainer build()
      Description copied from interface: ContainerBuilder
      Build the container.
    • start

      public HanaContainer start()
      Description copied from interface: ContainerBuilder
      Build and start the container.
    • mountsDirectory

      public HanaContainer.Builder mountsDirectory(String mountsDirectory)
      Set the path to the container-external mounts directory that can be used by the HANA docker image to store its data.
      Parameters:
      mountsDirectory - The path to the external directory
    • passwordsUrl

      public HanaContainer.Builder passwordsUrl(URL passwordsUrl)
      Set the URL of the file containing the default password(s) for the HANA database users.
      Parameters:
      passwordsUrl - The URL of the file containing the default password(s) for the HANA database users.
    • instanceNumber

      public HanaContainer.Builder instanceNumber(String instanceNumber)
      Set the container-external instance number of the HANA database.
      Parameters:
      instanceNumber - The container-external instance number of the HANA database.
    • agreeToSapLicense

      public HanaContainer.Builder agreeToSapLicense(boolean agreeToSapLicense)
      Set whether the user agrees to the SAP license for the HANA docker image.
      Parameters:
      agreeToSapLicense - Whether the user agrees to the license or not
      Returns:
    • getDbName

      protected String getDbName()
    • properties

      public HanaContainer.Builder properties(Properties properties)
      Load configuration from properties.
      Specified by:
      properties in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • adminUser

      public HanaContainer.Builder adminUser(String dbAdminUser)
      Set the password for the DB admin user.
      Specified by:
      adminUser in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • adminPassword

      public HanaContainer.Builder adminPassword(String adminPassword)
      Set the password for the DB admin user.
      Specified by:
      adminPassword in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • tmpfs

      public HanaContainer.Builder tmpfs(String tmpfs)
      Set the temp fs for in-memory use.
      Specified by:
      tmpfs in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • fastStartMode

      public HanaContainer.Builder fastStartMode(boolean fastStartMode)
      Defaults to true - If true ONLY check the existence of the DB and if present skip the other usual checks (does user exist, create extensions if not exists etc).
      Specified by:
      fastStartMode in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • dbName

      public HanaContainer.Builder dbName(String dbName)
      Set the DB name - e.g. my_app1, my_app2, my_app3 etc. Defaults to test_db.

      The DB name should not have any special characters (alpha and underscore) and should be unique for the project.

      ebean-test-docker is designed to share the same container across multiple projects. The way this works is that each project should have a unique db name. This means that as developers testing is faster as containers stay running and are shared and running tests for a project means setting up unique "database" using the dbName.

      Specified by:
      dbName in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • user

      public HanaContainer.Builder user(String user)
      Set the DB user. Defaults to being the same as the dbName.
      Specified by:
      user in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • password

      public HanaContainer.Builder password(String password)
      Set the DB password. Defaults to test.
      Specified by:
      password in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • schema

      public HanaContainer.Builder schema(String schema)
      Set the DB schema.
      Specified by:
      schema in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • characterSet

      public HanaContainer.Builder characterSet(String characterSet)
      Set the character set to use.
      Specified by:
      characterSet in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • collation

      public HanaContainer.Builder collation(String collation)
      Set the collation to use.
      Specified by:
      collation in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extensions

      public HanaContainer.Builder extensions(String extensions)
      Set the DB extensions to install in comma delimited form.

      Postgres hstore, pgcrypto etc.

      Example: .extensions("hstore,pgcrypto,uuid-ossp")

      Specified by:
      extensions in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • initSqlFile

      public HanaContainer.Builder initSqlFile(String initSqlFile)
      Set the SQL file to execute after creating the database.
      Specified by:
      initSqlFile in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • seedSqlFile

      public HanaContainer.Builder seedSqlFile(String seedSqlFile)
      Set the SQL file to execute after creating the database and initSqlFile.
      Specified by:
      seedSqlFile in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDb

      public HanaContainer.Builder extraDb(String extraDb)
      Set the name of an extra database to create.

      Use this when the application being tested uses 2 databases.

      Specified by:
      extraDb in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDbUser

      public HanaContainer.Builder extraDbUser(String extraDbUser)
      Set the name of an extra user to create. If an extra database is also created this would be the owner of that extra database.

      Use this when the application being tested uses 2 databases.

      Specified by:
      extraDbUser in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDbPassword

      public HanaContainer.Builder extraDbPassword(String extraDbPassword)
      Set the password for an extra user. If nothing is set this would default to be the same as the main users password.

      Use this when the application being tested uses 2 databases.

      Specified by:
      extraDbPassword in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDbExtensions

      public HanaContainer.Builder extraDbExtensions(String extraDbExtensions)
      Description copied from interface: ContainerBuilderDb
      Set extra database extensions.
      Specified by:
      extraDbExtensions in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDbInitSqlFile

      public HanaContainer.Builder extraDbInitSqlFile(String extraDbInitSqlFile)
      Set a file to execute after creating the extra database.
      Specified by:
      extraDbInitSqlFile in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • extraDbSeedSqlFile

      public HanaContainer.Builder extraDbSeedSqlFile(String extraDbSeedSqlFile)
      Set a file to execute after creating the extra database.
      Specified by:
      extraDbSeedSqlFile in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • inMemory

      public HanaContainer.Builder inMemory(boolean inMemory)
      Set to true to run using in memory storage for data via tmpfs.
      Specified by:
      inMemory in interface ContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C,SELF>>
    • initDefaultSchema

      protected void initDefaultSchema()
      Set the schema if it hasn't already set. Some databases (NuoDB) effectively require a default schema and it is reasonable for this to default to the username.
    • buildSummary

      protected String buildSummary()
      Return summary of the port db name and other details.
    • deriveUsername

      protected String deriveUsername()
    • internalConfig

      protected io.ebean.test.containers.InternalConfigDb internalConfig()
      Return the internal configuration.
    • docker

      protected String docker()
    • getHost

      protected String getHost()
    • getPort

      protected int getPort()
    • self

      protected HanaContainer.Builder self()
    • startMode

      public HanaContainer.Builder startMode(StartMode startMode)
      Description copied from interface: ContainerBuilder
      Set the start mode. One of create, dropCreate, or container [only].
      Specified by:
      startMode in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • shutdownMode

      public HanaContainer.Builder shutdownMode(StopMode shutdownMode)
      Description copied from interface: ContainerBuilder
      Set the shutdown hook mode to automatically stop/remove the container on JVM shutdown.
      Specified by:
      shutdownMode in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • prop

      protected String prop(Properties properties, String key, String defaultValue)
    • prop

      protected int prop(Properties properties, String key, int defaultValue)
    • containerName

      public HanaContainer.Builder containerName(String containerName)
      Set the container name.
      Specified by:
      containerName in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • mirror

      public HanaContainer.Builder mirror(String mirror)
      Set a container mirror for images to use with CI builds.

      For example "my.ecr/mirror".

      The mirror is not used when deemed to be running locally. Typically determined via a ~/.ebean/ignore-docker-shutdown file or alternative marker file set via system property ebean.test.localDevelopment>.

      Specified by:
      mirror in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • port

      public HanaContainer.Builder port(int port)
      Set the exposed port with 0 meaning use a random port.

      When the port is set to `0` then docker will assign a random port. This port is available after the container has started.

      
      
        LocalstackContainer container = LocalstackContainer.builder("0.14")
          .port(0)
          .build();
      
        container.start();
      
        int assignedPort = container.port();
      
        AmazonDynamoDB amazonDynamoDB = container.dynamoDB();
      
       
      Specified by:
      port in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • internalPort

      public HanaContainer.Builder internalPort(int internalPort)
      Set the internal (to the container) port.
      Specified by:
      internalPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • adminPort

      public HanaContainer.Builder adminPort(int adminPort)
      Set the exposed admin port.
      Specified by:
      adminPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • adminInternalPort

      public HanaContainer.Builder adminInternalPort(int adminInternalPort)
      Set the internal admin (to the container) port.
      Specified by:
      adminInternalPort in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • image

      public HanaContainer.Builder image(String image)
      Set the docker image to use.
      Specified by:
      image in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • maxReadyAttempts

      public HanaContainer.Builder maxReadyAttempts(int maxReadyAttempts)
      Set the max attempts to wait for DB ready.
      Specified by:
      maxReadyAttempts in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • docker

      public HanaContainer.Builder docker(String docker)
      Set the docker command to use (defaults to 'docker').
      Specified by:
      docker in interface ContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C,SELF>>
    • buildExtraJdbcUrl

      protected String buildExtraJdbcUrl()
      Override to build jdbc url for extraDb.
    • buildJdbcAdminUrl

      protected String buildJdbcAdminUrl()