The testing environment

Rationale

Code executed in R requires an environment, that manages the variables and R object used during execution. The latter is a data structure that provides the R programmer the ability to scope. Scoping makes available some variables visible from one element to another.

Test_that uses its own environment, that differs from the .GlobalEnv environment. The latter is used by default, when some R scripts and notebooks are interpreted and executed by R. By initialising, managing and clearing a new environment, then the DataSHIELD testing framework can provide all the tools and support every developer to write some tests. Also, any connections to an Opal server can be managed from the start to the end of some execution of tests.

ds.test_env environment

During its initialisation process, DataSHIELD testing framework creates the ds.test_env environment. The latter is destroyed once all the test have been executed. The ds.test_env environment defines the variables listed and described below. Each of them must be referred as ds.test_env$[name.variable].

Connection information

These variables are defined and initialised in the file /test/testthat/connection_to_datasets/login_details.R. These variables are either initialised by the functions named with init at the start (see https://data2knowledge.atlassian.net/wiki/spaces/DSDEV/pages/733052974 ) or in the /test/testthat/connection_to_datasets/login_details.R file.

Name of variables

Data Type

Description

Name of variables

Data Type

Description

ds.test_env$contexts

Vector of character

provides the values for the contexts of the tests; that is

  • opal

  • dsi

  • dslite

  • continuous

  • coverage

ds.test_env$context

Character

The current context of the test completed.

ds.test_env$package

Character

The name of the package that needs to be tested.

ds.test_env$ip_address_1

ds.test_env$ip_address_2

ds.test_env$ip_address_3

Character

holds the ip addresses to connect to the opal servers, used in the testing. These IP addresses are expressed as urls, to connect with Hypertext Transfer Protocol Secure (HTTPS). The corresponding port, i.e., 8443 is added to match the standard.

Example

https://192.168.56.100:8443

ds.test_env$ping_address

Character

This variable is used to verify an opal server is available with a specified IP address. A function provided by the RCurl library can test the reachability of the opal servers. To achieve this purpose the Hypertext Transfer Protocol is used, with the port. So, the variable stores this value:

http://192.168.56.100:8080

ds.test_env$user_1

ds.test_env$user_2

ds.test_env$user_3

Character

These three variables represent the user name used to connect the opal servers

ds.test_env$password_1

ds.test_env$password_2

ds.test_env$password_3

Character

These three variables hold the password corresponding to each user name. The combination of the users variables and the password allows to connect to the opal servers provided by the virtual machine.

ds.test_env$server

Vector of character

holds the name of the server(s) used in one test. The minimum length is one.

ds.test_env$url

Vector of character

contains the url(s) used to connect to the server. The latter use one of the ip_addresses (see above) variables or all of them.

ds.test_env$user

Vector of character

contains the user name(s) used to connect to one or several servers. The latter use one of the user (see above) variables or all of them.

ds.test_env$password

Vector of character

contains the password(s) required to login to one of more servers. The latter uses one of the password variable or all of them.

Testing data set

The testing dataset is described in this page Dataset for testing. These variables are set and initialised

These variables are either initialised by the functions named with init at the start (see https://data2knowledge.atlassian.net/wiki/spaces/DSDEV/pages/733052974 ) or in the /test/testthat/connection_to_datasets/login_details.R file.

Name of variables

Data Type

Description

Name of variables

Data Type

Description

ds.test_env$tolerance

Numerical

Sets the tolerance for accuracy in each test. It is currently set to 10-6

ds.test_env$table

Vector of character

holds the name of the tables stored on the opal server on the virtual machine. These tables are referred as:

  • TESTING.DATASET1

  • TESTING.DATASET2

  • TESTING.DATASET3

ds.test_env$login.data

Data frame

holds a server login data frame in a suitable format. The datashield.build.login.data.frame.o function guarantees the format and content is appropriate.

ds.test_env$stats.var

Vector of character

holds the list of column defined in TESTING data set. More information about these columns can be found in this page: Dataset for testing

ds.test_env$local.values.1

ds.test_env$local.values.2

ds.test_env$local.values.3

Data frame

Each of these data frames contains the same data as the data provided on the server. These data frames aims at computing some results locally. Then, these results can be compared with the some results obtained from a DataSHIELD function. These three data sets a method to verify the expected values.

ds.test_env$local.values

Data frame

When the three datasets used, this variable combines ds.test_env$local.values.1, ds.test_env$local.values.2 and ds.test_env$local.values.3. This variable can therefore be used to write some tests that combines the values from the three servers.