Skip to content

Commit f580215

Browse files
HUBS-1695 | Add example documentation for database specific VDB provision parameters.
1 parent f4e59cf commit f580215

File tree

18 files changed

+2270
-0
lines changed

18 files changed

+2270
-0
lines changed

docs/guides/provider_guide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Guide: <guide name> Delphix Provider Guide
2+
3+
## Delphix Provider Guide
4+
[We have provided a handful of examples in our GitHub repository to help you get a jump start with our Delphix Provider.](https://github.com/delphix-integrations/terraform-provider-delphix/tree/main/examples) These examples range from Terraform resource templates, quick Terraform examples, and full Jenkins pipelines. We update this repository based on our implementation experience, so be sure to check back for updates!
5+
If you have a suggested template, request, or modification, please submit it in our [GitHub Issues section.](https://github.com/delphix-integrations/terraform-provider-delphix)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Summary
2+
The Jenkinsfile presents a simple CI/CD scenario where it provisions a VDB, runs an automated test (like Selenium or JUnit) against that application & dataset, and then destroys the VDB. On testing failure, which will happen every time, a bookmark is created. This Jenksinfile leverages the DCT Terrafrom Provider and an API Curl command to show the full breadth of possibilites. All other steps are mocked out.
3+
4+
### Simple Getting Stated
5+
1) Create a Jenkinsfile Pipeline Job
6+
2) Insert or reference the associated `Jenkinsfile` file.
7+
- Note: This Jenkinsfile also references the Terraform files in the `../simple-provision` folder. Feel free to fork, update, and modify those.
8+
3) Update the following values:
9+
- DCT_HOSTNAME - Example: `10.134.0.1`
10+
- DCT_API_KEY - Example: `2.abc...`
11+
- [Manage this value through the Jenkins' Credentials plugin](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-secure-guide/injecting-secrets)
12+
- In a pinch, update it directly.
13+
- SOURCE_VDB - Example: `Oracle_QA`
14+
4) Run Jenkins Job
15+
16+
Note: I suggest you reduce the sleep timers in early testing scenarios .
17+
18+
19+
### Known Issues
20+
On VDB destroy, the underlying Bookmark's snapshot will be deleted and the Bookmark will become "dangling".
21+
Instead, I recommend using an "Enable/Disable" command instead of "Provision/Destroy" or skip the destroy VDB on failure.
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
pipeline {
2+
agent any
3+
4+
environment {
5+
def provision_successful = false
6+
def vdb_id = ""
7+
def vdb_name = ""
8+
def DCT_HOSTNAME = "<INSERT>"
9+
def SOURCE_VDB = "<INSERT>"
10+
test_error = 'false'
11+
}
12+
13+
stages {
14+
15+
stage ('Build Application') {
16+
steps {
17+
echo ('Building...')
18+
sleep (50)
19+
}
20+
}
21+
22+
stage ('Stand Up Full Application') {
23+
parallel {
24+
stage ('Apply Application Install') {
25+
steps{
26+
echo ('Provisioning Test App...')
27+
sleep (30)
28+
}
29+
}
30+
stage ('Create Database w/ Terraform') {
31+
steps {
32+
script {
33+
echo ('Provisioning VDB...')
34+
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/nick-mathison/delphix-terraform-examples.git'
35+
// sh ('ls -R')
36+
sh ('terraform -chdir=simple-provision init')
37+
withCredentials([string(credentialsId: 'DCT_API_KEY', variable: 'KEY')]) {
38+
sh ('terraform -chdir=simple-provision apply -var="source_data_id_1=$SOURCE_VDB" -var="dct_hostname=$DCT_HOSTNAME" -var="dct_api_key=$KEY" -auto-approve')
39+
}
40+
vdb_id = sh(script: 'terraform -chdir=simple-provision output vdb_id_1', returnStdout: true)
41+
vdb_id = vdb_id.replaceAll('\\"', "").trim()
42+
vdb_name = sh(script: 'terraform -chdir=simple-provision output vdb_name_1', returnStdout: true)
43+
echo ("vdb_id:" + vdb_id)
44+
echo ("vdb_name:" + vdb_name)
45+
provision_successful = true
46+
}
47+
}
48+
}
49+
}
50+
}
51+
52+
stage ('Combine') {
53+
steps {
54+
echo ('Combining...')
55+
sleep (10)
56+
}
57+
}
58+
59+
stage ('Run Tests') {
60+
parallel {
61+
stage ('UI') {
62+
stages {
63+
stage ('Run UI Tests') {
64+
steps{
65+
echo ('UI Tests...')
66+
sleep (150)
67+
}
68+
}
69+
stage ('Send UI Test Results') {
70+
steps{
71+
echo ('Send UI Test Results...')
72+
sleep (5)
73+
}
74+
}
75+
}
76+
}
77+
stage ('Unit') {
78+
stages {
79+
stage ('Run Unit Tests') {
80+
steps {
81+
script {
82+
echo ('Unit Tests...')
83+
sleep (70)
84+
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
85+
echo ('Identified 7 failing Unit Tests!')
86+
test_error = 'true';
87+
sh "exit 1"
88+
}
89+
}
90+
}
91+
}
92+
stage ('Send Unit Test Results') {
93+
steps{
94+
echo ('Send Unit Test Results...')
95+
sleep (6)
96+
}
97+
}
98+
}
99+
}
100+
stage ('Integ.') {
101+
stages {
102+
stage ('Run Integration Tests') {
103+
steps{
104+
echo ('UI Tests...')
105+
sleep (130)
106+
}
107+
}
108+
stage ('Send Integration Test Results') {
109+
steps{
110+
echo ('Send Integration Test Results...')
111+
sleep (4)
112+
}
113+
}
114+
}
115+
}
116+
}
117+
}
118+
119+
stage ('Bookmark Database') {
120+
when {
121+
equals expected: 'true', actual: test_error
122+
}
123+
steps{
124+
script {
125+
echo ('Bookmark VDB... ')
126+
withCredentials([string(credentialsId: 'DCT_API_KEY', variable: 'KEY')]) {
127+
sh """
128+
curl -X 'POST' -k \
129+
'https://$DCT_HOSTNAME/v3/bookmarks' \
130+
-H 'accept: application/json' \
131+
-H 'Authorization: apk ${KEY}' \
132+
-H 'Content-Type: application/json' \
133+
-d '{
134+
"name": "JKNS-BOOKMARK-$BUILD_NUMBER",
135+
"vdb_ids": [
136+
"${vdb_id}"
137+
],
138+
"retain_forever": true,
139+
"make_current_account_owner": true
140+
}'
141+
"""
142+
}
143+
}
144+
}
145+
}
146+
147+
stage ('Destroy Full Application') {
148+
parallel {
149+
stage ('Destroy Application') {
150+
steps {
151+
script {
152+
echo ('Destroying Application...')
153+
sleep (30)
154+
}
155+
}
156+
}
157+
stage ('Destroy Database w/ Terraform') {
158+
steps {
159+
script {
160+
if (provision_successful) {
161+
sleep (60)
162+
echo ('Destroying Test App and VDB...')
163+
withCredentials([string(credentialsId: 'DCT_API_KEY', variable: 'KEY')]) {
164+
sh ('terraform -chdir=simple-provision destroy -var="source_data_id_1=$SOURCE_VDB" -var="dct_hostname=$DCT_HOSTNAME" -var="dct_api_key=$KEY" -auto-approve')
165+
}
166+
} else {
167+
echo ('No App or VDB to destroy...')
168+
}
169+
}
170+
}
171+
}
172+
}
173+
}
174+
}
175+
}

examples/vdb/hana/bookmark/main.tf

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
terraform {
2+
required_providers {
3+
delphix = {
4+
version = "VERSION"
5+
source = "delphix-integrations/delphix"
6+
}
7+
}
8+
}
9+
10+
provider "delphix" {
11+
tls_insecure_skip = true
12+
key = "1.XXXX"
13+
host = "HOSTNAME"
14+
}
15+
16+
resource "delphix_vdb" "example" {
17+
bookmark_id = ""
18+
name = "vdb_to_be_created"
19+
source_data_id = "dsource-name"
20+
vdb_restart = true
21+
environment_id = "env-name"
22+
environment_user_id = "environment_user_name"
23+
target_group_id = "group-123"
24+
snapshot_policy_id = "test_snapshot_policy"
25+
database_name = "dbname_to_be_created"
26+
mount_point = "/var/mnt"
27+
auto_select_repository = true
28+
retention_policy_id = "test_retention_policy"
29+
custom_env_files = ["/export/home/env_file_1"]
30+
custom_env_vars = {
31+
MY_ENV_VAR1 = "$HOME"
32+
MY_ENV_VAR2 = "$CRS_HOME/after"
33+
}
34+
repository_id = ""
35+
appdata_source_params = jsonencode({
36+
mountLocation = "/mnt/bkmrk"
37+
configServices = [{
38+
"sTenantServicePort" = "indexserver:30049"
39+
},
40+
{
41+
"sTenantServicePort" = "xsengine:30052"
42+
}]
43+
tDatabaseName = "tfbkmrk"
44+
tSystemUserName = "SYSTEM"
45+
tSystemUserPassword ="Delphix_123"
46+
})
47+
config_params jsonencode({
48+
processes = 150
49+
})
50+
appdata_config_params jsonencode({
51+
param = "value"
52+
})
53+
additional_mount_points = [{
54+
shared_path = "/",
55+
mount_path = "/work",
56+
environment_id = "environment-123"
57+
}]
58+
make_current_account_owner = true
59+
tags {
60+
key = "key-1"
61+
value = "value-1"
62+
}
63+
post_snapshot {
64+
name = "string"
65+
command = "string"
66+
shell = "bash"
67+
element_id = "string"
68+
has_credentials = true
69+
}
70+
pre_snapshot {
71+
name = "string"
72+
command = "string"
73+
shell = "bash"
74+
element_id = "string"
75+
has_credentials = true
76+
}
77+
pre_stop {
78+
name = "string"
79+
command = "string"
80+
shell = "bash"
81+
element_id = "string"
82+
has_credentials = true
83+
}
84+
configure_clone {
85+
name = "string"
86+
command = "string"
87+
shell = "bash"
88+
element_id = "string"
89+
has_credentials = true
90+
}
91+
post_refresh {
92+
name = "string"
93+
command = "string"
94+
shell = "bash"
95+
element_id = "string"
96+
has_credentials = true
97+
}
98+
post_stop {
99+
name = "string"
100+
command = "string"
101+
shell = "bash"
102+
element_id = "string"
103+
has_credentials = true
104+
}
105+
post_rollback {
106+
name = "string"
107+
command = "string"
108+
shell = "bash"
109+
element_id = "string"
110+
has_credentials = true
111+
}
112+
post_start {
113+
name = "string"
114+
command = "string"
115+
shell = "bash"
116+
element_id = "string"
117+
has_credentials = true
118+
}
119+
pre_rollback {
120+
name = "string"
121+
command = "string"
122+
shell = "bash"
123+
element_id = "string"
124+
has_credentials = true
125+
}
126+
pre_start {
127+
name = "string"
128+
command = "string"
129+
shell = "bash"
130+
element_id = "string"
131+
has_credentials = true
132+
}
133+
pre_refresh {
134+
name = "string"
135+
command = "string"
136+
shell = "bash"
137+
element_id = "string"
138+
has_credentials = true
139+
}
140+
}

0 commit comments

Comments
 (0)