In this section:

Introduction

Enterprise Pack ships with MongoDB 4.0, but you can configure a set of environment variables included with Enterprise Pack to connect to a newer version of MongoDB. You can connect Enterprise Pack up to MongoDB 4.4.

You can either configure the environment variables externally (recommended) or edit the dtpservices startup script to control the MongoDB settings.

Configuring Environment Variables Externally

Specify the environment variables using your operating system's procedure. Refer to Environment Variables for details about the available variables.

Windows

The following instructions provide guidance on how to configure environment variables on Windows 10, but you should refer to the documentation for your version of Windows for details. 

  1. Open Control Panel from the Windows start menu.
  2. Choose System and Security > System > Advanced system settings.
  3. Choose Environment Variables to open the environment variables editing screen. 
  4. Add the Enterprise Pack variables for connecting to an external MongoDB in the System variables section. Refer to Environment Variables for information about the variables.
  5. Click OK to save the variables and restart the Enterprise Pack service (see Starting DTP Applications).

Linux

On Linux systems, you can configure the necessary environment variables before running the dtpconsole.sh script, e.g.:

export DEP_USE_REMOTE_DB=true
export DEP_DB_HOSTNAME=<HOST>
export DEP_DB_PORT=<PORT>
./dtpconsole.sh

Refer to Environment Variables for information about the variables.

You can also configure the system to set the variables you want to use at startup. For example, you could modify the environment file located in your /etc directory to include these variables. 

Editing the Startup Script

 You should always stop Enterprise Pack before making modifications to the script files.

If you are comfortable working with bash or shell scripts, you can specify the external MongoDB by editing the dtpservices file. The files are in the following locations:

  • Linux: <DTP_INSTALL>/dtpservices/dtpservices.sh
  • Windows: <DTP_INSTALL>/dtpservices/dtpservices.bat 

Refer to Environment Variables for information about the variables.

Authentication

If the MongoDB database is configured with authentication enabled, then the user configured in Enterprise Pack should at least have the readWrite role in the following databases:

  • administration
  • service-designer
  • service

In the following example, the mongo shell command creates a user in MongoDB that can be used by Enterprise Pack:

db.createUser({
    user: 'enterprise-pack',
    pwd: passwordPrompt(),
    roles: [
        { role: 'readWrite', db: 'administration' },
        { role: 'readWrite', db: 'service-designer' },
        { role: 'readWrite', db: 'service' }
    ]
})

Migrating Data to the Remote Database

  1. Start Enterprise Pack and run the following command to migrate data from the embedded database to the remote instance:

    <DTP_INSTALL>/dtpservices/mongodb/bin/mongodump --port=8316 --gzip --archive=dump.tar.gz

    The <DTP_INSTALL> directory should match the value of the -i parameter when running the DTP.sh installation script.

  2. Copy the dump.tar.gz file created by the command to the server hosting the remote MongoDB database.
  3. Ensure that the remote server is running and restore the data dumped from the embedded database. The following example command assumes that the mongorestore executable is on the system path. Additional options, such as --username and --password may be necessary based on the database configuration. 

    mongorestore --gzip --archive=dump.tar.gz

Your infrastructure may not be fully consistent with the instructions described in this documentation.  For example, you may first need to migrate the data into an older version of MongoDB on the remote system, then incrementally upgrade MongoDB until they are on the desired version of MongoDB. Refer to the MongoDB documentation for details about data migration: https://docs.mongodb.com/manual/tutorial/upgrade-revision/

Logging

The main.log file keeps track of DB connections. See Viewing Log Files for additional information. 

Example remote database log
[2021-05-24T15:35:35.771] [INFO] main - Configured to use a remote database. The embedded database will not be started.
[2021-05-24T15:35:35.774] [DEBUG] main - Connecting to database: mongodb://dtp-server2016.parasoft.com:27017/administration
[2021-05-24T15:35:35.828] [DEBUG] main - Connected to database: mongodb://dtp-server2016.parasoft.com:27017/administration
[2021-05-24T15:35:35.830] [DEBUG] main - Database connection is open: mongodb://dtp-server2016.parasoft.com:27017/administration
Example default database configuration log
2021-05-24T15:23:29.152] [INFO] main - Starting MongoDB.
[2021-05-24T15:23:29.193] [DEBUG] main - Connecting to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:31.202] [DEBUG] main - Connecting to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.212] [DEBUG] main - Connecting to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.267] [DEBUG] main - Connected to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.267] [DEBUG] main - Database connection is open: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.268] [DEBUG] main - Disconnecting from database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.273] [DEBUG] main - Database connection closed: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.274] [INFO] main - MongoDB is started.
[2021-05-24T15:23:33.274] [DEBUG] main - Connecting to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.336] [DEBUG] main - Connected to database: mongodb://localhost:8316/administration
[2021-05-24T15:23:33.338] [DEBUG] main - Database connection is open: mongodb://localhost:8316/administration

Environment Variables

You can configure the following environment variables to control the MongoDB settings:

VariableDescription
DEP_USE_REMOTE_DB 

Accepts a Boolean value that enables/disables starting Enterprise Pack using the embedded database. By default, the embedded database is used:

export DEP_USE_REMOTE_DB=false 

Set the variable to true to use a remote database.

DEP_DB_HOSTNAME 

Specifies the hostname for connecting to a remote database, e.g.:

export DEP_DB_HOSTNAME=localhost 

This variable is ignored if DEP_USE_REMOTE_DB=false 

Default value is localhost 

DEP_DB_PORT 

Specifies the port number for connecting to the database, e.g.:

export DEP_DB_PORT=8316 

You can use this variable to change the port number for connecting to the embedded database if DEP_USE_REMOTE_DB=false 

Default value is 8316 

DEP_DB_USERNAME 

Specifies the username for authenticating the connection to the database. This variable is optional and should only be used when the remote database has authentication enabled. Example:

export DEP_DB_USERNAME=<USERNAME>  

This variable is ignored if DEP_USE_REMOTE_DB=false 

DEP_DB_PASSWORD 

Specifies the password for authenticating the connection to the database. This variable is optional and should only be used when the remote database has authentication enabled. Example:

export DEP_DB_PASSWORD=<PASSWORD>  

This variable is ignored if DEP_USE_REMOTE_DB=false 

Passwords must be encrypted; plain text passwords are not supported. To encrypt this value use the -encodepass  CLI option included with any Parasoft tool (e.g., jtestcli.exe -encodepass <PASSWORD>).

DEP_AUTH_DB 

Specifies the database to use for authenticating the user. This variable is optional and should only be used when the remote database has authentication enabled. Example:

export DEP_AUTH_DB=test  

This variable is ignored if DEP_USE_REMOTE_DB=false 

  • No labels