9
9
"io"
10
10
"os"
11
11
"path/filepath"
12
+ "sigs.k8s.io/yaml"
12
13
"strings"
13
14
"testing"
14
15
"time"
@@ -54,13 +55,29 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
54
55
debugAndFailTest (ta , fmt .Sprintf ("file %s did not produce a pipelinerun: %#v" , runYamlPath , obj ))
55
56
}
56
57
57
- gavs := os .Getenv ("GAVS " )
58
+ set := os .Getenv ("TESTSET " )
58
59
//if the GAVS env var is set then we just create pre-defined GAVS
59
60
//otherwise we do a full build of a sample project
60
- if len (gavs ) > 0 {
61
+ if len (set ) > 0 {
62
+ bytes , err := os .ReadFile (filepath .Clean (filepath .Join (path , "minikube.yaml" )))
63
+ if err != nil {
64
+ debugAndFailTest (ta , err .Error ())
65
+ return
66
+ }
67
+ testData := map [string ][]string {}
68
+ err = yaml .Unmarshal (bytes , & testData )
69
+ if err != nil {
70
+ debugAndFailTest (ta , err .Error ())
71
+ return
72
+ }
61
73
62
- parts := strings .Split (gavs , "," )
74
+ parts := testData [set ]
75
+ if len (parts ) == 0 {
76
+ debugAndFailTest (ta , "No test data for " + set )
77
+ return
78
+ }
63
79
for _ , s := range parts {
80
+ ta .Logf (fmt .Sprintf ("Creating ArtifactBuild for GAV: %s" , s ))
64
81
ab := v1alpha1.ArtifactBuild {}
65
82
ab .Name = artifactbuild .CreateABRName (s )
66
83
ab .Namespace = ta .ns
@@ -122,7 +139,7 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
122
139
abList , err := jvmClient .JvmbuildserviceV1alpha1 ().ArtifactBuilds (ta .ns ).List (context .TODO (), metav1.ListOptions {})
123
140
if err != nil {
124
141
ta .Logf (fmt .Sprintf ("error list artifactbuilds: %s" , err .Error ()))
125
- return false , nil
142
+ return false , err
126
143
}
127
144
//we want to make sure there is more than one ab, and that they are all complete
128
145
abComplete := len (abList .Items ) > 0
@@ -137,21 +154,21 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
137
154
dbList , err := jvmClient .JvmbuildserviceV1alpha1 ().DependencyBuilds (ta .ns ).List (context .TODO (), metav1.ListOptions {})
138
155
if err != nil {
139
156
ta .Logf (fmt .Sprintf ("error list dependencybuilds: %s" , err .Error ()))
140
- return false , nil
157
+ return false , err
141
158
}
142
159
dbComplete := len (dbList .Items ) > 0
143
160
ta .Logf (fmt .Sprintf ("number of dependencybuilds: %d" , len (dbList .Items )))
144
161
dbCompleteCount := 0
145
162
for _ , db := range dbList .Items {
146
- if db .Status .State != v1alpha1 .DependencyBuildStateComplete {
163
+ if db .Status .State == v1alpha1 .DependencyBuildStateFailed {
164
+ ta .Logf (fmt .Sprintf ("depedencybuild %s FAILED" , db .Spec .ScmInfo .SCMURL ))
165
+ return false , fmt .Errorf ("depedencybuild %s for repo %s FAILED" , db .Name , db .Spec .ScmInfo .SCMURL )
166
+ } else if db .Status .State != v1alpha1 .DependencyBuildStateComplete {
147
167
if dbComplete {
148
168
//only print the first one
149
169
ta .Logf (fmt .Sprintf ("depedencybuild %s not complete" , db .Spec .ScmInfo .SCMURL ))
150
170
}
151
171
dbComplete = false
152
- } else if db .Status .State == v1alpha1 .DependencyBuildStateFailed {
153
- ta .Logf (fmt .Sprintf ("depedencybuild %s FAILED" , db .Spec .ScmInfo .SCMURL ))
154
- return false , fmt .Errorf ("depedencybuild %s for repo %s FAILED" , db .Name , db .Spec .ScmInfo .SCMURL )
155
172
} else if db .Status .State == v1alpha1 .DependencyBuildStateComplete {
156
173
dbCompleteCount ++
157
174
}
@@ -167,7 +184,7 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
167
184
}
168
185
})
169
186
170
- if len (gavs ) > 0 {
187
+ if len (set ) > 0 {
171
188
//no futher checks required here
172
189
//we are just checking that the GAVs in question actually build
173
190
return
0 commit comments