@@ -12,58 +12,131 @@ import java.util.zip.ZipFile
12
12
13
13
class BuildHadoopZips extends Specification {
14
14
15
- @Rule
16
- TemporaryFolder tmp = new TemporaryFolder ()
17
-
18
- def buildDotGradle
19
- def settingsDotGradle
20
- def gradleDotProperties
21
- def dotCrt
22
-
23
- def setup () {
24
- tmp. create()
25
- buildDotGradle = tmp. newFile(' build.gradle' )
26
- settingsDotGradle = tmp. newFile(' settings.gradle' )
27
- gradleDotProperties = tmp. newFile(' gradle.properties' )
28
- dotCrt = tmp. newFile(' .crt' )
29
- }
30
-
31
- /**
32
- * Integration test for including the sources zip and SCM metadata file in the Hadoop zip
33
- */
34
- def ' verify zip contents' () {
35
- given :
36
- def projectName = ' build-hadoop-zips'
37
- def version = ' 1.0.0'
38
- buildDotGradle << this . class. classLoader. getResource(' buildZips/buildZipsCRT.gradle' ). text
39
- settingsDotGradle << """ rootProject.name='${ projectName} '"""
40
- gradleDotProperties << """ version=${ version} """
41
- dotCrt << ''' Test .crt file\n '''
42
- GradleRunner runner = GradleRunner . create()
43
- .withProjectDir(tmp. root)
44
- .withPluginClasspath()
45
- .withArguments(' buildHadoopZips' , ' -is' )
46
-
47
- when :
48
- BuildResult result = runner. build()
49
-
50
- then :
51
- result. task(' :azkabanHadoopZip' ). outcome == TaskOutcome . SUCCESS
52
- result. task(' :CRTHadoopZip' ). outcome == TaskOutcome . SUCCESS
53
-
54
- // find CRTHadoopZip, assert contains .crt file (build/distributions/build-hadoop-zips-1.0.0.zip)
55
- def crtHadoopZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} .zip" )
56
- crtHadoopZip. exists()
57
- def crtHadoopZipContents = new ZipFile (crtHadoopZip)
58
- assert crtHadoopZipContents. getEntry(' .crt' ) != null
59
-
60
- // find azkabanHadoopZip, assert contents (build/distributions/build-hadoop-zips-1.0.0-azkaban.zip)
61
- // contents == build.gradle, buildMetadata.json, build-hadoop-zips-1.0.0-sources.zip
62
- def azkabanZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} -azkaban.zip" )
63
- azkabanZip. exists()
64
- def zipFileContents = new ZipFile (azkabanZip)
65
- zipFileContents. getEntry(' build.gradle' ) != null
66
- zipFileContents. getEntry(' buildMetadata.json' ) != null
67
- zipFileContents. getEntry(" ${ projectName} -${ version} -sources.zip" ) != null
68
- }
15
+ @Rule
16
+ TemporaryFolder tmp = new TemporaryFolder ()
17
+
18
+ def buildDotGradle
19
+ def settingsDotGradle
20
+ def gradleDotProperties
21
+ def dotCrt
22
+
23
+ def setup () {
24
+ tmp. create()
25
+ buildDotGradle = tmp. newFile(' build.gradle' )
26
+ settingsDotGradle = tmp. newFile(' settings.gradle' )
27
+ gradleDotProperties = tmp. newFile(' gradle.properties' )
28
+ dotCrt = tmp. newFile(' .crt' )
29
+ }
30
+
31
+ /**
32
+ * Integration test for including the sources zip and SCM metadata file in the Hadoop zip*/
33
+ def ' verify zip contents' () {
34
+ given :
35
+ def projectName = ' build-hadoop-zips'
36
+ def version = ' 1.0.0'
37
+ buildDotGradle << this . class. classLoader. getResource(' buildZips/buildZipsCRT.gradle' ). text
38
+ settingsDotGradle << """ rootProject.name='${ projectName} '"""
39
+ gradleDotProperties << """ version=${ version} """
40
+ dotCrt << ''' Test .crt file\n '''
41
+ GradleRunner runner = GradleRunner . create()
42
+ .withProjectDir(tmp. root)
43
+ .withPluginClasspath()
44
+ .withArguments(' buildHadoopZips' , ' -is' )
45
+
46
+ when :
47
+ BuildResult result = runner. build()
48
+
49
+ then :
50
+ result. task(' :azkabanHadoopZip' ). outcome == TaskOutcome . SUCCESS
51
+ result. task(' :CRTHadoopZip' ). outcome == TaskOutcome . SUCCESS
52
+
53
+ // find CRTHadoopZip, assert contains .crt file (build/distributions/build-hadoop-zips-1.0.0.zip)
54
+ def crtHadoopZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} .zip" )
55
+ crtHadoopZip. exists()
56
+ def crtHadoopZipContents = new ZipFile (crtHadoopZip)
57
+ assert crtHadoopZipContents. getEntry(' .crt' ) != null
58
+
59
+ // find azkabanHadoopZip, assert contents (build/distributions/build-hadoop-zips-1.0.0-azkaban.zip)
60
+ // contents == build.gradle, buildMetadata.json, build-hadoop-zips-1.0.0-sources.zip
61
+ def azkabanZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} -azkaban.zip" )
62
+ azkabanZip. exists()
63
+ def zipFileContents = new ZipFile (azkabanZip)
64
+ zipFileContents. getEntry(' build.gradle' ) != null
65
+ zipFileContents. getEntry(' buildMetadata.json' ) != null
66
+ zipFileContents. getEntry(" ${ projectName} -${ version} -sources.zip" ) != null
67
+ }
68
+
69
+ def ' verify zip contents doesnt include buildMetadata when asked' () {
70
+ given :
71
+ def projectName = ' build-hadoop-zips'
72
+ def version = ' 1.0.0'
73
+ buildDotGradle << this . class. classLoader. getResource(' buildZips/buildZipsCRT.gradle' ). text
74
+ settingsDotGradle << """ rootProject.name='${ projectName} '"""
75
+ gradleDotProperties << """ version=${ version} \n disableScmPluginMetaData=true\n """
76
+ dotCrt << ''' Test .crt file\n '''
77
+ GradleRunner runner = GradleRunner . create()
78
+ .withProjectDir(tmp. root)
79
+ .withPluginClasspath()
80
+ .withArguments(' buildHadoopZips' , ' -is' )
81
+ .forwardOutput()
82
+ .withDebug(true )
83
+
84
+ when :
85
+ BuildResult result = runner. build()
86
+
87
+ then :
88
+ result. task(' :azkabanHadoopZip' ). outcome == TaskOutcome . SUCCESS
89
+ result. task(' :CRTHadoopZip' ). outcome == TaskOutcome . SUCCESS
90
+
91
+ // find CRTHadoopZip, assert contains .crt file (build/distributions/build-hadoop-zips-1.0.0.zip)
92
+ def crtHadoopZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} .zip" )
93
+ crtHadoopZip. exists()
94
+ def crtHadoopZipContents = new ZipFile (crtHadoopZip)
95
+ assert crtHadoopZipContents. getEntry(' .crt' ) != null
96
+
97
+ // find azkabanHadoopZip, assert contents (build/distributions/build-hadoop-zips-1.0.0-azkaban.zip)
98
+ // contents == build.gradle, buildMetadata.json, build-hadoop-zips-1.0.0-sources.zip
99
+ def azkabanZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} -azkaban.zip" )
100
+ azkabanZip. exists()
101
+ def zipFileContents = new ZipFile (azkabanZip)
102
+ zipFileContents. getEntry(' build.gradle' ) != null
103
+ zipFileContents. getEntry(' buildMetadata.json' ) == null
104
+ zipFileContents. getEntry(" ${ projectName} -${ version} -sources.zip" ) != null
105
+ }
106
+
107
+ def ' verify zip contents doesnt include buildMetadata AND sources when asked' () {
108
+ given :
109
+ def projectName = ' build-hadoop-zips'
110
+ def version = ' 1.0.0'
111
+ buildDotGradle << this . class. classLoader. getResource(' buildZips/buildZipsCRT.gradle' ). text
112
+ settingsDotGradle << """ rootProject.name='${ projectName} '"""
113
+ gradleDotProperties << """ version=${ version} \n disableScmPluginMetaData=true\n disableScmPlugin=true"""
114
+ dotCrt << ''' Test .crt file\n '''
115
+ GradleRunner runner = GradleRunner . create()
116
+ .withProjectDir(tmp. root)
117
+ .withPluginClasspath()
118
+ .withArguments(' buildHadoopZips' , ' -is' )
119
+
120
+ when :
121
+ BuildResult result = runner. build()
122
+
123
+ then :
124
+ result. task(' :azkabanHadoopZip' ). outcome == TaskOutcome . SUCCESS
125
+ result. task(' :CRTHadoopZip' ). outcome == TaskOutcome . SUCCESS
126
+
127
+ // find CRTHadoopZip, assert contains .crt file (build/distributions/build-hadoop-zips-1.0.0.zip)
128
+ def crtHadoopZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} .zip" )
129
+ crtHadoopZip. exists()
130
+ def crtHadoopZipContents = new ZipFile (crtHadoopZip)
131
+ assert crtHadoopZipContents. getEntry(' .crt' ) != null
132
+
133
+ // find azkabanHadoopZip, assert contents (build/distributions/build-hadoop-zips-1.0.0-azkaban.zip)
134
+ // contents == build.gradle, buildMetadata.json, build-hadoop-zips-1.0.0-sources.zip
135
+ def azkabanZip = new File (tmp. root, " build/distributions/${ projectName} -${ version} -azkaban.zip" )
136
+ azkabanZip. exists()
137
+ def zipFileContents = new ZipFile (azkabanZip)
138
+ zipFileContents. getEntry(' build.gradle' ) != null
139
+ zipFileContents. getEntry(' buildMetadata.json' ) == null
140
+ zipFileContents. getEntry(" ${ projectName} -${ version} -sources.zip" ) == null
141
+ }
69
142
}
0 commit comments