@@ -51,16 +51,17 @@ var addNumbersComponent = &pipelinespec.ComponentSpec{
5151}
5252
5353// Tests that launcher correctly executes the user component and successfully writes output parameters to file.
54- func Test_executeV2_Parameters (t * testing.T ) {
55- customLocalPath := "/tmp/custom/artifact.txt"
54+ func Test_executeV2_Artifacts (t * testing.T ) {
55+ uri := "gs:///tmp/custom/artifact.txt"
56+ custom := "mem://test-bucket/pipeline-root/temp.txt"
5657 tests := []struct {
5758 name string
5859 executorInput * pipelinespec.ExecutorInput
5960 executorArgs []string
6061 wantErr bool
6162 }{
6263 {
63- "happy pass " ,
64+ "custom path " ,
6465 & pipelinespec.ExecutorInput {
6566 Inputs : & pipelinespec.ExecutorInput_Inputs {
6667 ParameterValues : map [string ]* structpb.Value {"a" : structpb .NewNumberValue (1 ), "b" : structpb .NewNumberValue (2 )},
@@ -70,7 +71,11 @@ func Test_executeV2_Parameters(t *testing.T) {
7071 "dataset" : {
7172 Artifacts : []* pipelinespec.RuntimeArtifact {
7273 {
73- Uri : customLocalPath ,
74+ Uri : uri ,
75+ CustomPath : & custom ,
76+ Type : & pipelinespec.ArtifactTypeSchema {
77+ Kind : & pipelinespec.ArtifactTypeSchema_InstanceSchema {InstanceSchema : "title: kfp.Model\n type: object\n properties:\n framework:\n type: string\n framework_version:\n type: string\n " },
78+ },
7479 },
7580 },
7681 },
@@ -80,6 +85,83 @@ func Test_executeV2_Parameters(t *testing.T) {
8085 []string {"-c" , "test {{$.inputs.parameters['a']}} -eq 1 || exit 1\n test {{$.inputs.parameters['b']}} -eq 2 || exit 1" },
8186 false ,
8287 },
88+ {
89+ "default path" ,
90+ & pipelinespec.ExecutorInput {
91+ Inputs : & pipelinespec.ExecutorInput_Inputs {
92+ ParameterValues : map [string ]* structpb.Value {"b" : structpb .NewNumberValue (2 )},
93+ },
94+ Outputs : & pipelinespec.ExecutorInput_Outputs {
95+ Artifacts : map [string ]* pipelinespec.ArtifactList {
96+ "dataset" : {
97+ Artifacts : []* pipelinespec.RuntimeArtifact {
98+ {
99+ Uri : uri ,
100+ CustomPath : & custom ,
101+ Type : & pipelinespec.ArtifactTypeSchema {
102+ Kind : & pipelinespec.ArtifactTypeSchema_InstanceSchema {InstanceSchema : "title: kfp.Model\n type: object\n properties:\n framework:\n type: string\n framework_version:\n type: string\n " },
103+ },
104+ },
105+ },
106+ },
107+ },
108+ },
109+ },
110+ []string {"-c" , "test {{$.inputs.parameters['a']}} -eq 5 || exit 1\n test {{$.inputs.parameters['b']}} -eq 2 || exit 1" },
111+ false ,
112+ },
113+ }
114+
115+ for _ , test := range tests {
116+ t .Run (test .name , func (t * testing.T ) {
117+ fakeKubernetesClientset := & fake.Clientset {}
118+ fakeMetadataClient := metadata .NewFakeClient ()
119+ bucket , err := blob .OpenBucket (context .Background (), "mem://test-bucket" )
120+ assert .Nil (t , err )
121+ bucketConfig , err := objectstore .ParseBucketConfig ("mem://test-bucket/pipeline-root/" , nil )
122+ assert .Nil (t , err )
123+ _ , _ , err = executeV2 (
124+ context .Background (),
125+ test .executorInput ,
126+ addNumbersComponent ,
127+ "sh" ,
128+ test .executorArgs ,
129+ bucket ,
130+ bucketConfig ,
131+ fakeMetadataClient ,
132+ "namespace" ,
133+ fakeKubernetesClientset ,
134+ "false" ,
135+ )
136+ //
137+ //if test.wantErr {
138+ // assert.NotNil(t, err)
139+ //} else {
140+ // assert.Nil(t, err)
141+ //}
142+ assert .NotEmpty (t , bucket )
143+ })
144+ }
145+ }
146+
147+ // Tests that launcher correctly executes the user component and successfully writes output parameters to file.
148+ func Test_executeV2_Parameters (t * testing.T ) {
149+ tests := []struct {
150+ name string
151+ executorInput * pipelinespec.ExecutorInput
152+ executorArgs []string
153+ wantErr bool
154+ }{
155+ {
156+ "happy pass" ,
157+ & pipelinespec.ExecutorInput {
158+ Inputs : & pipelinespec.ExecutorInput_Inputs {
159+ ParameterValues : map [string ]* structpb.Value {"a" : structpb .NewNumberValue (1 ), "b" : structpb .NewNumberValue (2 )},
160+ },
161+ },
162+ []string {"-c" , "test {{$.inputs.parameters['a']}} -eq 1 || exit 1\n test {{$.inputs.parameters['b']}} -eq 2 || exit 1" },
163+ false ,
164+ },
83165 {
84166 "use default value" ,
85167 & pipelinespec.ExecutorInput {
0 commit comments