// Module included in the following assemblies:
//
// * backup_and_restore/application_backup_and_restore/oadp-data-protection-test.adoc

:_mod-docs-content-type: PROCEDURE
[id="using-data-protection-test_{context}"]
= Using the DataProtectionTest custom resource

[role="_abstract"]
You can configure the `DataProtectionTest` (DPT) custom resource (CR) and then run the DPT CR to verify the Container Storage Initiative (CSI) snapshot readiness and the data upload performance to the storage bucket.

.Prerequisites

* You have logged in to the {product-title} cluster as a user with the `cluster-admin` role.
* You have installed the OpenShift CLI (`oc`).
* You have installed the {oadp-short} Operator.
* You have created the `DataProtectionApplication` (DPA) CR.
* You have configured a backup storage location (BSL) to store the backups.
* You have an application with persistent volume claims (PVCs) running in a separate namespace.


.Procedure

.  Create a manifest file for the DPT CR as shown in the example:
+
[source,yaml]
----
apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionTest
metadata:
  name: dpt-sample
  namespace: openshift-adp
spec:
  backupLocationName: <bsl_name> # <1>
  csiVolumeSnapshotTestConfigs: # <2>
  - snapshotClassName: csi-gce-pd-vsc 
    timeout: 90s
    volumeSnapshotSource:
      persistentVolumeClaimName: <pvc1_name> # <3>
      persistentVolumeClaimNamespace: <pvc_namespace> # <4>
  - snapshotClassName: csi-gce-pd-vsc
    timeout: 120s
    volumeSnapshotSource:
      persistentVolumeClaimName: <pvc2_name> # <5>
      persistentVolumeClaimNamespace: <pvc_namespace>
  forceRun: false # <6> 
  uploadSpeedTestConfig: # <7>
    fileSize: 200MB
    timeout: 120s
----
<1> Specify the name of the BSL.
<2> Specify a list for `csiVolumeSnapshotTestConfigs`. In this example, two PVCs are being tested.
<3> Specify the name of the first PVC.
<4> Specify the namespace of the PVC.
<5> Specify the name of the second PVC.
<6> Set the `forceRun` flag to `false` if you want to make the {oadp-short} controller skip re-running tests.
<7> Configure the `uploadSpeedTestConfig` object by setting the `fileSize` and `timeout` fields.

. Create the DPT CR by running the following command:
+
[source,terminal]
----
$ oc create -f <dpt_file_name> # <1>
----
<1> Specify the file name of the DPT manifest.


.Verification

. Verify that the phase of the DPT CR is `Complete` by running the following command:
+
[source,terminal]
----
$ oc get dpt dpt-sample
----
+
The example output is as following:
+
[source,terminal]
----
NAME         PHASE      LASTTESTED   UPLOADSPEED(MBPS)   ENCRYPTION   VERSIONING   SNAPSHOTS    AGE
dpt-sample   Complete   17m          546                 AES256       Enabled      2/2 passed   17m
----

. Verify that the CSI snapshots are ready and the data upload tests are successful by running the following command:
+
[source,terminal]
----
$ oc get dpt dpt-sample -o yaml
----
+
The example output is as following:
+
[source,yaml]
----
apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionTest
....
status:
  bucketMetadata: # <1>
    encryptionAlgorithm: AES256
    versioningStatus: Enabled
  lastTested: "202...:47:51Z"
  phase: Complete
  s3Vendor: AWS # <2>
  snapshotSummary: 2/2 passed # <3>
  snapshotTests:
  - persistentVolumeClaimName: mysql-data
    persistentVolumeClaimNamespace: ocp-mysql
    readyDuration: 24s
    status: Ready
  - persistentVolumeClaimName: mysql-data1
    persistentVolumeClaimNamespace: ocp-mysql
    readyDuration: 40s
    status: Ready
  uploadTest: # <4>
    duration: 3.071s
    speedMbps: 546
    success: true
----
<1> The bucket metadata information.
<2> The S3 bucket vendor.
<3> Summary of the CSI snapshot tests.
<4> The upload test details.