Creating a physical database resource

After you create a logical database server in your project, you must create a physical database resource in HCL OneTest API and configure it with the details of the database that you set up in a Kubernetes cluster.

Before you begin

You must have completed the following tasks:
  • Created the physical connection with the Kubernetes cluster in your project. See Configuring a physical connection to a Kubernetes cluster.
  • Noted the details about the database that you set up in a Kubernetes cluster:
    • The database URL that identifies the service or pod in the cluster.
      You can use include any of the following identities:
      • Service name and service port.
      • Service DNS name. For example, my_service.my_namespace
      • Pod name and container port.
      Note: If the service DNS name is used then the namespace provided in the name overrides the namespace that is configured in the Kubernetes cluster resource.
  • Created a logical database resource in your project. See Creating a logical database resource.

Procedure

  1. Open the Logical View of HCL OneTest API Architecture School perspective, if it is not already open.
  2. Select the logical database resource that you created.
  3. Right-click the database resource, and select Physical Resource.

    The Unknown database dialog is displayed.

  4. Configure the connection details for the different options as listed in the following table in the Connection tab:
    Table 1. Database connection options
    Option Action
    Maximum Number of Connections Enter the maximum number of database connections from HCL OneTest API that are to be available in the pool. If you leave this field blank, the value defaults to 1.
    Tip: You must increase the value if you run multiple tests that use the same database resource concurrently.
    Driver
    Select the database driver for the specified database type from the drop-down list or enter the driver class name if the database driver is not listed.
    Note: Drivers that are installed and added through the Library Manager are displayed, and are prefixed with User Defined followed by the name of the driver in parenthesis. For example, User Defined (<name of the driver>).
    Database URL Enter the connection URL for the database. You can modify the default URL after you select one of the included drivers. The database URL must begin with the format as follows so that the host and port can be extracted and used to identify the Kubernetes service or pod in the cluster.
    <scheme>[separator]<host>[:<port>]
    For example, the supported database URL is as follows:
    jdbc:derby://database-service:1527/db
    The following table lists the connection URL patterns that are supported by HCL OneTest API:
    Note: The port can be omitted for known JDBC drivers, in which case the default port for that driver will be used.
    Table 2. Supported URL patterns
    Database driver URL pattern Default port
    IBM® Db2® Universal
    jdbc:db2//database-service:50000/db
    50000
    IBM® Db2® iSeries
    jdbc:as400//database-service:446/db
    446
    Derby
    jdbc:derby//database-service:1527/db
    1527
    Composite Software JDBC
    jdbc:compositesw:dbapi@database-service:9401?
    9401
    Microsoft SQL Server
    jdbc:jtds:sqlserver//database-service:1433/db
    jdbc:sqlserver://database-service;db
    1433
    Oracle
    jdbc:oracle:thin:database-service:1521/db
    1521
    PostgreSQL
    jdbc:postgresql//database-service:5432/db
    5432
    Sybase jConnect
    jdbc:sybase:Tds//database-service:5000/db
    5000
    Username/Password Enter a valid user name and password combination to send when you are connecting to the database. Both fields support tags, but the menu is not supported in the Password field.
    Database Schema Enter the name of the database schema to switch to when a connection is established. This field is optional and you can use it to access database tables outside of your default database schema.
    Note: To access the database schema, you might need to grant the user access to that schema. For example, GRANT access value ON SCHEMA schema name to USER user name.
  5. Click the Advanced tab, and perform the following steps:
    1. Select the Enable Kubernetes proxy option.
    2. Click Browse.

      The Select a Resource dialog is displayed.

    3. Locate and select the physical Kubernetes cluster resource.
    4. Click OK.
  6. Click the Connection tab, and then click Test Connection to test the connection between HCL OneTest API and the database in the Kubernetes cluster.
  7. Click OK to complete the configuration of the database connection.

Results

You created a physical database resource in your project and tested the connection with the database in the Kubernetes cluster.

What to do next

You can create tests or stubs to use the database in the Kubernetes cluster.