Skip to content

Commit bfe77fd

Browse files
committed
add repo agnosticism to e2e/integration tests
Signed-off-by: Humair Khan <[email protected]> # Conflicts: # backend/test/integration/pipeline_api_test.go # backend/test/integration/pipeline_version_api_test.go # backend/test/integration/upgrade_test.go # backend/test/testutil/test_utils.go # backend/test/v2/integration/pipeline_api_test.go # backend/test/v2/integration/pipeline_version_api_test.go
1 parent c6d702d commit bfe77fd

File tree

9 files changed

+98
-51
lines changed

9 files changed

+98
-51
lines changed

.github/workflows/integration-tests-v1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
id: integration-tests
7474
if: ${{ steps.forward-mysql-port.outcome == 'success' }}
7575
working-directory: ./backend/test/integration
76-
run: go test -v ./... -args -runIntegrationTests=true -namespace=kubeflow
76+
run: go test -v ./... -args -runIntegrationTests=true -namespace=kubeflow -repoName=${{ github.repository }} -branchName=${{ github.ref_name }}
7777
env:
7878
PULL_NUMBER: ${{ github.event.pull_request.number }}
7979
continue-on-error: true

.github/workflows/legacy-v2-api-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
id: tests
8484
if: ${{ steps.forward-mlmd-port.outcome == 'success' }}
8585
working-directory: ./backend/test/v2/integration
86-
run: go test -v ./... -args -runIntegrationTests=true -namespace=kubeflow -tlsEnabled=${{ matrix.pod_to_pod_tls_enabled }} -caCertPath=${{ env.CA_CERT_PATH }}
86+
run: go test -v ./... -args -runIntegrationTests=true -namespace=kubeflow -tlsEnabled=${{ matrix.pod_to_pod_tls_enabled }} -caCertPath=${{ env.CA_CERT_PATH }} -repoName=${{ github.repository }} -branchName=${{ github.ref_name }}
8787
env:
8888
PULL_NUMBER: ${{ github.event.pull_request.number }}
8989
PIPELINE_STORE: ${{ matrix.pipeline_store }}

backend/src/common/client/api_server/v2/pipeline_client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package api_server_v2
1717
import (
1818
"crypto/tls"
1919
"fmt"
20+
2021
"github.com/go-openapi/runtime"
2122
"github.com/go-openapi/strfmt"
2223
apiclient "github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/pipeline_client"

backend/test/integration/pipeline_api_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package integration
1616

1717
import (
18-
"fmt"
1918
"os"
2019
"testing"
2120
"time"
@@ -24,10 +23,11 @@ import (
2423
model "github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_model"
2524
uploadParams "github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_upload_client/pipeline_upload_service"
2625
pipelinetemplate "github.com/kubeflow/pipelines/backend/src/apiserver/template"
27-
api_server "github.com/kubeflow/pipelines/backend/src/common/client/api_server/v1"
26+
"github.com/kubeflow/pipelines/backend/src/common/client/api_server/v1"
2827
"github.com/kubeflow/pipelines/backend/src/common/util"
2928
"github.com/kubeflow/pipelines/backend/test"
3029
"github.com/kubeflow/pipelines/backend/test/config"
30+
"github.com/kubeflow/pipelines/backend/test/testutil"
3131

3232
"github.com/golang/glog"
3333
"github.com/stretchr/testify/assert"
@@ -45,6 +45,8 @@ import (
4545
type PipelineApiTest struct {
4646
suite.Suite
4747
namespace string
48+
repoName string
49+
branchName string
4850
resourceNamespace string
4951
pipelineClient *api_server.PipelineClient
5052
pipelineUploadClient *api_server.PipelineUploadClient
@@ -64,6 +66,8 @@ func (s *PipelineApiTest) SetupTest() {
6466
}
6567
}
6668
s.namespace = *config.Namespace
69+
s.repoName = *config.REPO_NAME
70+
s.branchName = *config.BRANCH_NAME
6771

6872
var newPipelineUploadClient func() (*api_server.PipelineUploadClient, error)
6973
var newPipelineClient func() (*api_server.PipelineClient, error)
@@ -123,10 +127,12 @@ func (s *PipelineApiTest) TestPipelineAPI() {
123127
assert.Contains(t, err.Error(), "Failed to upload pipeline")
124128

125129
/* ---------- Import pipeline YAML by URL ---------- */
130+
pipelineURL, err := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential.yaml")
131+
require.Nil(t, err)
126132
time.Sleep(1 * time.Second)
127133
sequentialPipeline, err := s.pipelineClient.Create(&params.PipelineServiceCreatePipelineV1Params{
128134
Pipeline: &model.APIPipeline{Name: "sequential", URL: &model.APIURL{
129-
PipelineURL: "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential.yaml",
135+
PipelineURL: pipelineURL,
130136
}},
131137
})
132138
require.Nil(t, err)
@@ -140,11 +146,8 @@ func (s *PipelineApiTest) TestPipelineAPI() {
140146
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.Name)
141147

142148
/* ---------- Import pipeline tarball by URL ---------- */
143-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/v2/resources/arguments_parameters.zip"
144-
145-
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
146-
pipelineURL = fmt.Sprintf("https://raw.githubusercontent.com/kubeflow/pipelines/pull/%s/head/backend/test/v2/resources/arguments_parameters.zip", pullNumber)
147-
}
149+
pipelineURL, err = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/arguments_parameters.zip")
150+
require.Nil(t, err)
148151

149152
time.Sleep(1 * time.Second)
150153
argumentUrlPipeline, err := s.pipelineClient.Create(&params.PipelineServiceCreatePipelineV1Params{

backend/test/integration/pipeline_version_api_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package integration
1616

1717
import (
18-
"fmt"
1918
"os"
2019
"testing"
2120
"time"
@@ -24,10 +23,11 @@ import (
2423
"github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_model"
2524
uploadParams "github.com/kubeflow/pipelines/backend/api/v1beta1/go_http_client/pipeline_upload_client/pipeline_upload_service"
2625
pipelinetemplate "github.com/kubeflow/pipelines/backend/src/apiserver/template"
27-
api_server "github.com/kubeflow/pipelines/backend/src/common/client/api_server/v1"
26+
"github.com/kubeflow/pipelines/backend/src/common/client/api_server/v1"
2827
"github.com/kubeflow/pipelines/backend/src/common/util"
2928
"github.com/kubeflow/pipelines/backend/test"
3029
"github.com/kubeflow/pipelines/backend/test/config"
30+
"github.com/kubeflow/pipelines/backend/test/testutil"
3131

3232
"github.com/golang/glog"
3333
"github.com/stretchr/testify/assert"
@@ -43,6 +43,8 @@ import (
4343
type PipelineVersionApiTest struct {
4444
suite.Suite
4545
namespace string
46+
repoName string
47+
branchName string
4648
pipelineClient *api_server.PipelineClient
4749
pipelineUploadClient *api_server.PipelineUploadClient
4850
}
@@ -84,6 +86,9 @@ func (s *PipelineVersionApiTest) SetupTest() {
8486
}
8587
}
8688

89+
s.repoName = *config.REPO_NAME
90+
s.branchName = *config.BRANCH_NAME
91+
8792
var err error
8893
s.pipelineUploadClient, err = newPipelineUploadClient()
8994
if err != nil {
@@ -143,12 +148,14 @@ func (s *PipelineVersionApiTest) TestArgoSpec() {
143148
assert.Contains(t, err.Error(), "Failed to upload pipeline version")
144149

145150
/* ---------- Import pipeline version YAML by URL ---------- */
151+
pipelineURL, err := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential.yaml")
152+
require.Nil(t, err)
146153
time.Sleep(1 * time.Second)
147154
sequentialPipelineVersion, err := s.pipelineClient.CreatePipelineVersion(&params.PipelineServiceCreatePipelineVersionV1Params{
148155
Version: &pipeline_model.APIPipelineVersion{
149156
Name: "sequential",
150157
PackageURL: &pipeline_model.APIURL{
151-
PipelineURL: "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential.yaml",
158+
PipelineURL: pipelineURL,
152159
},
153160
ResourceReferences: []*pipeline_model.APIResourceReference{
154161
{
@@ -173,11 +180,8 @@ func (s *PipelineVersionApiTest) TestArgoSpec() {
173180

174181
/* ---------- Import pipeline tarball by URL ---------- */
175182
time.Sleep(1 * time.Second)
176-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/resources/arguments_parameters.zip"
177-
178-
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
179-
pipelineURL = fmt.Sprintf("https://raw.githubusercontent.com/kubeflow/pipelines/pull/%s/head/backend/test/resources/arguments_parameters.zip", pullNumber)
180-
}
183+
pipelineURL, err = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/resources/arguments_parameters.zip")
184+
require.Nil(t, err)
181185

182186
argumentUrlPipelineVersion, err := s.pipelineClient.CreatePipelineVersion(&params.PipelineServiceCreatePipelineVersionV1Params{
183187
Version: &pipeline_model.APIPipelineVersion{

backend/test/integration/upgrade_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/kubeflow/pipelines/backend/src/common/util"
3535
"github.com/kubeflow/pipelines/backend/test"
3636
"github.com/kubeflow/pipelines/backend/test/config"
37+
"github.com/kubeflow/pipelines/backend/test/testutil"
3738

3839
"github.com/go-openapi/strfmt"
3940
"github.com/golang/glog"
@@ -50,6 +51,8 @@ import (
5051
type UpgradeTests struct {
5152
suite.Suite
5253
namespace string
54+
repoName string
55+
branchName string
5356
resourceNamespace string
5457
experimentClient *api_server.ExperimentClient
5558
pipelineClient *api_server.PipelineClient
@@ -101,6 +104,7 @@ func (s *UpgradeTests) SetupSuite() {
101104
}
102105
}
103106
s.namespace = *config.Namespace
107+
s.repoName = *config.REPO_NAME
104108

105109
var newExperimentClient func() (*api_server.ExperimentClient, error)
106110
var newPipelineUploadClient func() (*api_server.PipelineUploadClient, error)
@@ -273,11 +277,8 @@ func (s *UpgradeTests) PreparePipelines() {
273277
assert.Equal(t, "arguments-parameters.yaml", argumentYAMLPipeline.Name)
274278

275279
/* ---------- Import pipeline YAML by URL ---------- */
276-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/test_data/sdk_compiled_pipelines/valid/sequential_v1.yaml"
277-
278-
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
279-
pipelineURL = fmt.Sprintf("https://raw.githubusercontent.com/kubeflow/pipelines/pull/%s/head/test_data/sdk_compiled_pipelines/valid/sequential_v1.yaml", pullNumber)
280-
}
280+
pipelineURL, err := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "test_data/sdk_compiled_pipelines/valid/sequential_v1.yaml")
281+
require.Nil(t, err)
281282
time.Sleep(1 * time.Second)
282283
sequentialPipeline, err := s.pipelineClient.Create(&pipelineParams.PipelineServiceCreatePipelineV1Params{
283284
Pipeline: &pipeline_model.APIPipeline{Name: "sequential", URL: &pipeline_model.APIURL{
@@ -295,12 +296,8 @@ func (s *UpgradeTests) PreparePipelines() {
295296
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.Name)
296297

297298
/* ---------- Import pipeline tarball by URL ---------- */
298-
pipelineURL = "https://github.com/kubeflow/pipelines/raw/refs/heads/master/test_data/sdk_compiled_pipelines/valid/arguments_parameters.zip"
299-
300-
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
301-
pipelineURL = fmt.Sprintf("https://raw.githubusercontent.com/kubeflow/pipelines/pull/%s/head/test_data/sdk_compiled_pipelines/valid/arguments_parameters.zip", pullNumber)
302-
}
303-
299+
pipelineURL, err = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "test_data/sdk_compiled_pipelines/valid/arguments_parameters.zip")
300+
require.Nil(t, err)
304301
time.Sleep(1 * time.Second)
305302
argumentUrlPipeline, err := s.pipelineClient.Create(&pipelineParams.PipelineServiceCreatePipelineV1Params{
306303
Pipeline: &pipeline_model.APIPipeline{

backend/test/testutil/test_utils.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"crypto/x509"
2121
"fmt"
2222
"math/rand"
23+
"net/http"
2324
"os"
2425
"path/filepath"
2526
"regexp"
@@ -179,3 +180,44 @@ func GetTLSConfig(caCertPath string) (*tls.Config, error) {
179180
RootCAs: caCertPool,
180181
}, nil
181182
}
183+
184+
func GetRepoBranchURLRAW(repoName, branch, path string) (string, error) {
185+
url := fmt.Sprintf("https://github.com/%s/raw/refs/heads/%s/%s", repoName, branch, path)
186+
187+
pullNumber := os.Getenv("PULL_NUMBER")
188+
if pullNumber != "" {
189+
url = fmt.Sprintf("https://raw.githubusercontent.com/%s/pull/%s/head/%s", repoName, pullNumber, path)
190+
}
191+
192+
// Verify the URL exists
193+
resp, err := http.Head(url)
194+
if err != nil {
195+
return url, fmt.Errorf("failed to verify URL exists: %s\n"+
196+
"Error: %v\n"+
197+
"This may indicate network issues or the file doesn't exist at the specified location.\n"+
198+
"Repository: %s, Branch/PR: %s, Path: %s",
199+
url, err, repoName, getBranchOrPR(pullNumber, branch), path)
200+
}
201+
defer func() {
202+
if closeErr := resp.Body.Close(); closeErr != nil {
203+
logger.Log("Warning: failed to close response body: %v", closeErr)
204+
}
205+
}()
206+
207+
if resp.StatusCode != http.StatusOK {
208+
msg := "URL verification failed with status %d: %s, " +
209+
"the file does not exist at the specified location, " +
210+
"repository: %s, Branch/PR: %s, Path: %s"
211+
return url, fmt.Errorf(msg, resp.StatusCode, url, repoName, getBranchOrPR(pullNumber, branch), path)
212+
}
213+
214+
return url, nil
215+
}
216+
217+
// getBranchOrPR returns a human-readable string indicating whether we're using a branch or PR
218+
func getBranchOrPR(pullNumber, branch string) string {
219+
if pullNumber != "" {
220+
return fmt.Sprintf("PR #%s", pullNumber)
221+
}
222+
return fmt.Sprintf("branch '%s'", branch)
223+
}

backend/test/v2/integration/pipeline_api_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ package integration
1616

1717
import (
1818
"crypto/tls"
19-
"fmt"
20-
"os"
2119
"testing"
2220
"time"
2321

@@ -27,6 +25,7 @@ import (
2725
api_server "github.com/kubeflow/pipelines/backend/src/common/client/api_server/v2"
2826
"github.com/kubeflow/pipelines/backend/src/common/util"
2927
"github.com/kubeflow/pipelines/backend/test/config"
28+
"github.com/kubeflow/pipelines/backend/test/testutil"
3029
test "github.com/kubeflow/pipelines/backend/test/v2"
3130

3231
"github.com/golang/glog"
@@ -44,6 +43,8 @@ import (
4443
type PipelineApiTest struct {
4544
suite.Suite
4645
namespace string
46+
repoName string
47+
branchName string
4748
resourceNamespace string
4849
pipelineClient *api_server.PipelineClient
4950
pipelineUploadClient api_server.PipelineUploadInterface
@@ -63,6 +64,8 @@ func (s *PipelineApiTest) SetupTest() {
6364
}
6465
}
6566
s.namespace = *config.Namespace
67+
s.repoName = *config.REPO_NAME
68+
s.branchName = *config.BRANCH_NAME
6669

6770
var newPipelineClient func() (*api_server.PipelineClient, error)
6871
var tlsCfg *tls.Config
@@ -148,6 +151,8 @@ func (s *PipelineApiTest) TestPipelineAPI() {
148151
assert.Contains(t, err.Error(), "Failed to upload pipeline")
149152

150153
/* ---------- Import pipeline YAML by URL ---------- */
154+
pipelineURL, err := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential-v2.yaml")
155+
require.Nil(t, err)
151156
time.Sleep(1 * time.Second)
152157
sequentialPipeline, err := s.pipelineClient.CreatePipelineAndVersion(&params.PipelineServiceCreatePipelineAndVersionParams{
153158
Body: &model.V2beta1CreatePipelineAndVersionRequest{
@@ -158,7 +163,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
158163
},
159164
PipelineVersion: &model.V2beta1PipelineVersion{
160165
PackageURL: &model.V2beta1URL{
161-
PipelineURL: "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential-v2.yaml",
166+
PipelineURL: pipelineURL,
162167
},
163168
},
164169
},
@@ -175,7 +180,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
175180
assert.Equal(t, "sequential", sequentialPipelineVersions[0].DisplayName)
176181
assert.Equal(t, "sequential pipeline", sequentialPipelineVersions[0].Description)
177182
assert.Equal(t, sequentialPipeline.PipelineID, sequentialPipelineVersions[0].PipelineID)
178-
assert.Equal(t, "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential-v2.yaml", string(sequentialPipelineVersions[0].PackageURL.PipelineURL))
183+
assert.Equal(t, pipelineURL, sequentialPipelineVersions[0].PackageURL.PipelineURL)
179184

180185
/* ---------- Upload pipelines zip ---------- */
181186
time.Sleep(1 * time.Second)
@@ -185,12 +190,8 @@ func (s *PipelineApiTest) TestPipelineAPI() {
185190
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.DisplayName)
186191

187192
/* ---------- Import pipeline tarball by URL ---------- */
188-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/v2/resources/arguments_parameters.zip"
189-
190-
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
191-
pipelineURL = fmt.Sprintf("https://raw.githubusercontent.com/kubeflow/pipelines/pull/%s/head/backend/test/v2/resources/arguments_parameters.zip", pullNumber)
192-
}
193-
193+
pipelineURL, err = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/arguments_parameters.zip")
194+
require.Nil(t, err)
194195
time.Sleep(1 * time.Second)
195196
argumentUrlPipeline, err := s.pipelineClient.Create(&params.PipelineServiceCreatePipelineParams{
196197
Pipeline: &model.V2beta1Pipeline{DisplayName: "arguments_parameters.zip", Name: "arguments-pipeline-zip"},
@@ -212,7 +213,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
212213
assert.Equal(t, "argumenturl-v1", argumentUrlPipelineVersion.DisplayName)
213214
assert.Equal(t, "1st version of argument url pipeline", argumentUrlPipelineVersion.Description)
214215
assert.Equal(t, argumentUrlPipeline.PipelineID, argumentUrlPipelineVersion.PipelineID)
215-
assert.Equal(t, pipelineURL, string(argumentUrlPipelineVersion.PackageURL.PipelineURL))
216+
assert.Equal(t, pipelineURL, argumentUrlPipelineVersion.PackageURL.PipelineURL)
216217

217218
/* ---------- Verify list pipeline works ---------- */
218219
pipelines, totalSize, _, err := s.pipelineClient.List(&params.PipelineServiceListPipelinesParams{})

0 commit comments

Comments
 (0)