Skip to content

Commit 5f997e8

Browse files
Merge pull request redhat-appstudio#801 from stuartwdouglas/new-test-repos
STONEBLD-1575 Initial setup of new tests
2 parents d7bc70e + 319cda7 commit 5f997e8

File tree

8 files changed

+54
-24
lines changed

8 files changed

+54
-24
lines changed

.github/workflows/minikube.yaml

+7-5
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ jobs:
7373
path: /tmp/jvm-build-service-report
7474
run-gav-based-tests:
7575
strategy:
76+
fail-fast: false
7677
matrix:
77-
gavs:
78-
- "commons-collections:commons-collections:3.2.2,org.apache.commons:commons-lang3:3.12.0"
79-
- "org.xerial.snappy:snappy-java:1.1.8.4,org.lz4:lz4-java:1.8.0,org.lz4:lz4-pure-java:1.8.0"
78+
testsets:
79+
- "test-repos"
80+
- "build-systems"
81+
- "commons"
8082
needs: [wait-for-images]
8183
runs-on: ubuntu-latest
8284
name: Minikube GAV Matrix
@@ -109,13 +111,13 @@ jobs:
109111
docker tag quay.io/redhat-appstudio/pull-request-builds:jvmcache-${{ github.event.pull_request.head.sha }} quay.io/minikube/hacbs-jvm-cache:dev
110112
docker tag quay.io/redhat-appstudio/pull-request-builds:jvmcontroller-${{ github.event.pull_request.head.sha }} quay.io/minikube/hacbs-jvm-controller:dev
111113
112-
export GAVS=${{ matrix.gavs }}
114+
export TESTSET=${{ matrix.testsets }}
113115
114116
./deploy/minikube-ci.sh
115117
make minikube-test
116118
- name: Archive Report
117119
uses: actions/upload-artifact@v3
118120
if: always()
119121
with:
120-
name: matrix-report
122+
name: matrix-report-${{ matrix.testsets }}
121123
path: /tmp/jvm-build-service-report

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ require (
2828
github.com/redhat-appstudio/remote-secret v0.0.0-20230713072146-a6094c712436
2929
github.com/redhat-appstudio/service-provider-integration-operator v0.2023.22-0.20230713080056-eae17aa8c172
3030
go.uber.org/zap v1.24.0
31+
sigs.k8s.io/yaml v1.3.0
3132
)
3233

3334
require (
@@ -115,5 +116,4 @@ require (
115116
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
116117
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
117118
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
118-
sigs.k8s.io/yaml v1.3.0 // indirect
119119
)

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/build/LookupBuildInfoCommand.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.HashSet;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.Objects;
2223
import java.util.Set;
2324

2425
import jakarta.enterprise.inject.Instance;
@@ -170,7 +171,8 @@ private void doBuildAnalysis(String scmUrl, String scmTag, String context, Build
170171
if (model.getVersion() != null && model.getVersion().endsWith("-SNAPSHOT")) {
171172
//not tagged properly, deal with it automatically
172173
info.enforceVersion = version;
173-
} else if (model.getVersion().equals(version)) {
174+
} else if (model.getVersion() == null || Objects.equals(version, model.getVersion())) {
175+
//if the version is null we can't run enforce version at this point
174176
//version is correct, don't run enforce version as it can fail on things
175177
//that are tagged correctly
176178
versionCorrect = true;

java-components/cache/src/main/java/com/redhat/hacbs/artifactcache/artifactwatch/ScmLookup.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ void setup() {
5959

6060
@Override
6161
public void onAdd(ArtifactBuild newObj) {
62-
62+
if (newObj.getStatus() == null) {
63+
newObj.setStatus(new ArtifactBuildStatus());
64+
}
6365
for (var i = 0; i < 3; ++i) { //retry loop
6466
if (newObj.getStatus() == null || newObj.getStatus().getState() == null
6567
|| Objects.equals(newObj.getStatus().getState(), "")
@@ -83,9 +85,6 @@ public void onAdd(ArtifactBuild newObj) {
8385
scm.setPath(result.getRepoInfo().getPath());
8486
scm.set_private(result.getRepoInfo().isPrivateRepo());
8587
scm.setTag(result.getTag());
86-
if (newObj.getStatus() == null) {
87-
newObj.setStatus(new ArtifactBuildStatus());
88-
}
8988
newObj.getStatus().setScm(scm);
9089
newObj.getStatus().setMessage("");
9190
newObj.getStatus().setState(ModelConstants.ARTIFACT_BUILD_DISCOVERING);

openshift-with-appstudio-test/e2e/basictests.go

+27-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"os"
1111
"path/filepath"
12+
"sigs.k8s.io/yaml"
1213
"strings"
1314
"testing"
1415
"time"
@@ -54,13 +55,29 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
5455
debugAndFailTest(ta, fmt.Sprintf("file %s did not produce a pipelinerun: %#v", runYamlPath, obj))
5556
}
5657

57-
gavs := os.Getenv("GAVS")
58+
set := os.Getenv("TESTSET")
5859
//if the GAVS env var is set then we just create pre-defined GAVS
5960
//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+
}
6173

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+
}
6379
for _, s := range parts {
80+
ta.Logf(fmt.Sprintf("Creating ArtifactBuild for GAV: %s", s))
6481
ab := v1alpha1.ArtifactBuild{}
6582
ab.Name = artifactbuild.CreateABRName(s)
6683
ab.Namespace = ta.ns
@@ -122,7 +139,7 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
122139
abList, err := jvmClient.JvmbuildserviceV1alpha1().ArtifactBuilds(ta.ns).List(context.TODO(), metav1.ListOptions{})
123140
if err != nil {
124141
ta.Logf(fmt.Sprintf("error list artifactbuilds: %s", err.Error()))
125-
return false, nil
142+
return false, err
126143
}
127144
//we want to make sure there is more than one ab, and that they are all complete
128145
abComplete := len(abList.Items) > 0
@@ -137,21 +154,21 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
137154
dbList, err := jvmClient.JvmbuildserviceV1alpha1().DependencyBuilds(ta.ns).List(context.TODO(), metav1.ListOptions{})
138155
if err != nil {
139156
ta.Logf(fmt.Sprintf("error list dependencybuilds: %s", err.Error()))
140-
return false, nil
157+
return false, err
141158
}
142159
dbComplete := len(dbList.Items) > 0
143160
ta.Logf(fmt.Sprintf("number of dependencybuilds: %d", len(dbList.Items)))
144161
dbCompleteCount := 0
145162
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 {
147167
if dbComplete {
148168
//only print the first one
149169
ta.Logf(fmt.Sprintf("depedencybuild %s not complete", db.Spec.ScmInfo.SCMURL))
150170
}
151171
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)
155172
} else if db.Status.State == v1alpha1.DependencyBuildStateComplete {
156173
dbCompleteCount++
157174
}
@@ -167,7 +184,7 @@ func runPipelineTests(t *testing.T, doSetup func(t *testing.T, namespace string)
167184
}
168185
})
169186

170-
if len(gavs) > 0 {
187+
if len(set) > 0 {
171188
//no futher checks required here
172189
//we are just checking that the GAVs in question actually build
173190
return
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
commons:
2+
- "commons-collections:commons-collections:3.2.2"
3+
- "org.apache.commons:commons-lang3:3.12.0"
4+
build-systems:
5+
- "org.xerial.snappy:snappy-java:1.1.8.4"
6+
- "org.lz4:lz4-java:1.8.0"
7+
- "org.lz4:lz4-pure-java:1.8.0"
8+
test-repos:
9+
- "io.github.jvm-build-service-test-data.maven-version-from-parent-enforce-version:maven-version-from-parent-enforce-version:1.0"

openshift-with-appstudio-test/e2e/util.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,8 @@ func setupMinikube(t *testing.T, namespace string) *testArgs {
856856
Annotations: map[string]string{jbsconfig.TestRegistry: "true"},
857857
},
858858
Spec: v1alpha1.JBSConfigSpec{
859-
EnableRebuilds: true,
859+
EnableRebuilds: true,
860+
AdditionalRecipes: []string{"https://github.com/jvm-build-service-test-data/recipe-repo"},
860861
BuildSettings: v1alpha1.BuildSettings{
861862
BuildRequestMemory: "256Mi",
862863
TaskRequestMemory: "256Mi",

pkg/reconciler/jbsconfig/jbsconfig.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ func (r *ReconcilerJBSConfig) cacheDeployment(ctx context.Context, log logr.Logg
461461
"memory": resource.MustParse(settingOrDefault(jbsConfig.Spec.CacheSettings.LimitMemory, v1alpha1.ConfigArtifactCacheLimitMemoryDefault)),
462462
"cpu": resource.MustParse(settingOrDefault(jbsConfig.Spec.CacheSettings.LimitCPU, v1alpha1.ConfigArtifactCacheLimitCPUDefault))},
463463
},
464-
LivenessProbe: &corev1.Probe{TimeoutSeconds: 15, ProbeHandler: corev1.ProbeHandler{HTTPGet: &corev1.HTTPGetAction{Path: "/q/health/live", Port: intstr.FromInt(8080)}}},
465-
ReadinessProbe: &corev1.Probe{ProbeHandler: corev1.ProbeHandler{HTTPGet: &corev1.HTTPGetAction{Path: "/q/health/ready", Port: intstr.FromInt(8080)}}},
464+
StartupProbe: &corev1.Probe{FailureThreshold: 120, PeriodSeconds: 1, ProbeHandler: corev1.ProbeHandler{HTTPGet: &corev1.HTTPGetAction{Path: "/q/health/live", Port: intstr.FromInt(8080)}}},
465+
LivenessProbe: &corev1.Probe{FailureThreshold: 3, PeriodSeconds: 5, ProbeHandler: corev1.ProbeHandler{HTTPGet: &corev1.HTTPGetAction{Path: "/q/health/live", Port: intstr.FromInt(8080)}}},
466466
}}
467467
cache.Spec.Template.Spec.Volumes = []corev1.Volume{
468468
{Name: v1alpha1.CacheDeploymentName, VolumeSource: corev1.VolumeSource{PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: v1alpha1.CacheDeploymentName}}},

0 commit comments

Comments
 (0)