Skip to content

Commit 6e4fc9c

Browse files
committed
add repo agnosticism to e2e/integration tests
Signed-off-by: Humair Khan <[email protected]>
1 parent 91b1b36 commit 6e4fc9c

File tree

10 files changed

+65
-61
lines changed

10 files changed

+65
-61
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.event.repository.default_branch }}
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 -repoName=${{ github.repository }} -branchName=${{ github.event.repository.default_branch }}
8787
env:
8888
PULL_NUMBER: ${{ github.event.pull_request.number }}
8989
PIPELINE_STORE: ${{ matrix.pipeline_store }}

backend/src/apiserver/server/pipeline_upload_server_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ const (
4747
func TestUploadPipeline(t *testing.T) {
4848
// TODO(v2): when we add a field to distinguish between v1 and v2 template, verify it's in the response
4949
tt := []struct {
50-
name string
51-
spec []byte
50+
name string
51+
spec []byte
5252
apiVersion string
5353
}{{
54-
name: "upload argo workflow YAML",
55-
spec: []byte("apiVersion: argoproj.io/v1alpha1\nkind: Workflow"),
54+
name: "upload argo workflow YAML",
55+
spec: []byte("apiVersion: argoproj.io/v1alpha1\nkind: Workflow"),
5656
apiVersion: "v1beta1",
5757
}, {
58-
name: "upload argo workflow YAML",
59-
spec: []byte("apiVersion: argoproj.io/v1alpha1\nkind: Workflow"),
58+
name: "upload argo workflow YAML",
59+
spec: []byte("apiVersion: argoproj.io/v1alpha1\nkind: Workflow"),
6060
apiVersion: "v2beta1",
6161
}, {
62-
name: "upload pipeline v2 job in proto yaml",
63-
spec: []byte(v2SpecHelloWorld),
62+
name: "upload pipeline v2 job in proto yaml",
63+
spec: []byte(v2SpecHelloWorld),
6464
apiVersion: "v1beta1",
6565
}, {
66-
name: "upload pipeline v2 job in proto yaml",
67-
spec: []byte(v2SpecHelloWorld),
66+
name: "upload pipeline v2 job in proto yaml",
67+
spec: []byte(v2SpecHelloWorld),
6868
apiVersion: "v2beta1",
6969
}}
7070
for _, test := range tt {

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: 9 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,11 @@ func (s *PipelineApiTest) TestPipelineAPI() {
123127
assert.Contains(t, err.Error(), "Failed to upload pipeline")
124128

125129
/* ---------- Import pipeline YAML by URL ---------- */
130+
pipelineURL := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential.yaml")
126131
time.Sleep(1 * time.Second)
127132
sequentialPipeline, err := s.pipelineClient.Create(&params.PipelineServiceCreatePipelineV1Params{
128133
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",
134+
PipelineURL: pipelineURL,
130135
}},
131136
})
132137
require.Nil(t, err)
@@ -140,11 +145,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
140145
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.Name)
141146

142147
/* ---------- Import pipeline tarball by URL ---------- */
143-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/v2/resources/arguments.pipeline.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.pipeline.zip", pullNumber)
147-
}
148+
pipelineURL = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/arguments.pipeline.zip")
148149

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

backend/test/integration/pipeline_version_api_test.go

Lines changed: 10 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,13 @@ 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 := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential.yaml")
146152
time.Sleep(1 * time.Second)
147153
sequentialPipelineVersion, err := s.pipelineClient.CreatePipelineVersion(&params.PipelineServiceCreatePipelineVersionV1Params{
148154
Version: &pipeline_model.APIPipelineVersion{
149155
Name: "sequential",
150156
PackageURL: &pipeline_model.APIURL{
151-
PipelineURL: "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential.yaml",
157+
PipelineURL: pipelineURL,
152158
},
153159
ResourceReferences: []*pipeline_model.APIResourceReference{
154160
{
@@ -173,11 +179,7 @@ func (s *PipelineVersionApiTest) TestArgoSpec() {
173179

174180
/* ---------- Import pipeline tarball by URL ---------- */
175181
time.Sleep(1 * time.Second)
176-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/resources/arguments.pipeline.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.pipeline.zip", pullNumber)
180-
}
182+
pipelineURL = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/resources/arguments.pipeline.zip")
181183

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

backend/test/integration/upgrade_test.go

Lines changed: 6 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,7 @@ 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 := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "test_data/sdk_compiled_pipelines/valid/sequential_v1.yaml")
281281
time.Sleep(1 * time.Second)
282282
sequentialPipeline, err := s.pipelineClient.Create(&pipelineParams.PipelineServiceCreatePipelineV1Params{
283283
Pipeline: &pipeline_model.APIPipeline{Name: "sequential", URL: &pipeline_model.APIURL{
@@ -295,12 +295,7 @@ func (s *UpgradeTests) PreparePipelines() {
295295
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.Name)
296296

297297
/* ---------- Import pipeline tarball by URL ---------- */
298-
pipelineURL = "https://github.com/kubeflow/pipelines/raw/refs/heads/master/test_data/sdk_compiled_pipelines/valid/arguments.pipeline.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.pipeline.zip", pullNumber)
302-
}
303-
298+
pipelineURL = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "test_data/sdk_compiled_pipelines/valid/arguments.pipeline.zip")
304299
time.Sleep(1 * time.Second)
305300
argumentUrlPipeline, err := s.pipelineClient.Create(&pipelineParams.PipelineServiceCreatePipelineV1Params{
306301
Pipeline: &pipeline_model.APIPipeline{

backend/test/testutil/test_utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,12 @@ func ReplaceSDKInPipelineSpec(pipelineFilePath string, cacheDisabled bool, defau
118118

119119
return []byte(modifiedPipelineSpec)
120120
}
121+
122+
func GetRepoBranchURLRAW(repoName, branch, path string) string {
123+
url := fmt.Sprintf("https://github.com/%s/raw/refs/heads/%s/%s", repoName, branch, path)
124+
125+
if pullNumber := os.Getenv("PULL_NUMBER"); pullNumber != "" {
126+
url = fmt.Sprintf("https://raw.githubusercontent.com/%s/pull/%s/head/%s", repoName, pullNumber, path)
127+
}
128+
return url
129+
}

backend/test/v2/integration/pipeline_api_test.go

Lines changed: 10 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,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
148151
assert.Contains(t, err.Error(), "Failed to upload pipeline")
149152

150153
/* ---------- Import pipeline YAML by URL ---------- */
154+
pipelineURL := testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/sequential-v2.yaml")
151155
time.Sleep(1 * time.Second)
152156
sequentialPipeline, err := s.pipelineClient.CreatePipelineAndVersion(&params.PipelineServiceCreatePipelineAndVersionParams{
153157
Body: &model.V2beta1CreatePipelineAndVersionRequest{
@@ -158,7 +162,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
158162
},
159163
PipelineVersion: &model.V2beta1PipelineVersion{
160164
PackageURL: &model.V2beta1URL{
161-
PipelineURL: "https://raw.githubusercontent.com/kubeflow/pipelines/refs/heads/master/backend/test/v2/resources/sequential-v2.yaml",
165+
PipelineURL: pipelineURL,
162166
},
163167
},
164168
},
@@ -175,7 +179,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
175179
assert.Equal(t, "sequential", sequentialPipelineVersions[0].DisplayName)
176180
assert.Equal(t, "sequential pipeline", sequentialPipelineVersions[0].Description)
177181
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))
182+
assert.Equal(t, pipelineURL, sequentialPipelineVersions[0].PackageURL.PipelineURL)
179183

180184
/* ---------- Upload pipelines zip ---------- */
181185
time.Sleep(1 * time.Second)
@@ -185,12 +189,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
185189
assert.Equal(t, "zip-arguments-parameters", argumentUploadPipeline.DisplayName)
186190

187191
/* ---------- Import pipeline tarball by URL ---------- */
188-
pipelineURL := "https://github.com/kubeflow/pipelines/raw/refs/heads/master/backend/test/v2/resources/arguments.pipeline.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.pipeline.zip", pullNumber)
192-
}
193-
192+
pipelineURL = testutil.GetRepoBranchURLRAW(s.repoName, s.branchName, "backend/test/v2/resources/arguments.pipeline.zip")
194193
time.Sleep(1 * time.Second)
195194
argumentUrlPipeline, err := s.pipelineClient.Create(&params.PipelineServiceCreatePipelineParams{
196195
Pipeline: &model.V2beta1Pipeline{DisplayName: "arguments.pipeline.zip", Name: "arguments-pipeline-zip"},
@@ -212,7 +211,7 @@ func (s *PipelineApiTest) TestPipelineAPI() {
212211
assert.Equal(t, "argumenturl-v1", argumentUrlPipelineVersion.DisplayName)
213212
assert.Equal(t, "1st version of argument url pipeline", argumentUrlPipelineVersion.Description)
214213
assert.Equal(t, argumentUrlPipeline.PipelineID, argumentUrlPipelineVersion.PipelineID)
215-
assert.Equal(t, pipelineURL, string(argumentUrlPipelineVersion.PackageURL.PipelineURL))
214+
assert.Equal(t, pipelineURL, argumentUrlPipelineVersion.PackageURL.PipelineURL)
216215

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

0 commit comments

Comments
 (0)