11package datadog.trace.instrumentation.spark
22
3+ import datadog.trace.test.util.DDSpecification
34import org.apache.spark.SparkConf
4- import spock.lang.Specification
55
6- class OpenlineageParentContextTest extends Specification {
6+ class OpenlineageParentContextTest extends DDSpecification {
77 def " should create OpenLineageParentContext with particular trace id based on root parent id" () {
88 given :
9+ injectSysConfig(" data.jobs.openlineage.enabled" , " true" )
910 SparkConf mockSparkConf = Mock (SparkConf )
1011
1112 when :
@@ -38,6 +39,7 @@ class OpenlineageParentContextTest extends Specification {
3839
3940 def " should create empty OpenLineageParentContext if any required field is missing" () {
4041 given :
42+ injectSysConfig(" data.jobs.openlineage.enabled" , " true" )
4143 SparkConf mockSparkConf = Mock (SparkConf )
4244
4345 when :
@@ -66,6 +68,7 @@ class OpenlineageParentContextTest extends Specification {
6668
6769 def " should only generate a non-empty OpenlineageParentContext if parentRunId is a valid UUID" () {
6870 given :
71+ injectSysConfig(" data.jobs.openlineage.enabled" , " true" )
6972 SparkConf mockSparkConf = Mock (SparkConf )
7073
7174 when :
@@ -94,6 +97,7 @@ class OpenlineageParentContextTest extends Specification {
9497
9598 def " should only generate a non-empty OpenlineageParentContext if rootParentRunId is a valid UUID" () {
9699 given :
100+ injectSysConfig(" data.jobs.openlineage.enabled" , " true" )
97101 SparkConf mockSparkConf = Mock (SparkConf )
98102
99103 when :
@@ -119,5 +123,21 @@ class OpenlineageParentContextTest extends Specification {
119123 " 6afeb6ee-729d-37f7-b8e6f47ca694" | false
120124 " 6AFEB6EE-729D-37F7-AD73-B8E6F47CA694" | true
121125 }
126+
127+ def " should create empty OpenLineageParentContext if data jobs openlineage not enabled" () {
128+ given :
129+ injectSysConfig(" data.jobs.openlineage.enabled" , " falsebrn" )
130+ SparkConf mockSparkConf = Mock (SparkConf )
131+
132+ when :
133+ mockSparkConf. contains(OpenlineageParentContext . OPENLINEAGE_PARENT_JOB_NAMESPACE ) >> true
134+ mockSparkConf. contains(OpenlineageParentContext . OPENLINEAGE_PARENT_JOB_NAME ) >> true
135+ mockSparkConf. contains(OpenlineageParentContext . OPENLINEAGE_PARENT_RUN_ID ) >> true
136+ mockSparkConf. contains(OpenlineageParentContext . OPENLINEAGE_ROOT_PARENT_RUN_ID ) >> true
137+
138+ then :
139+ Optional<OpenlineageParentContext > parentContext = OpenlineageParentContext . from(mockSparkConf)
140+ ! parentContext. isPresent()
141+ }
122142}
123143
0 commit comments