@@ -31,6 +31,7 @@ import (
31
31
"github.com/pkg/errors"
32
32
"github.com/spf13/viper"
33
33
"github.com/stretchr/testify/assert"
34
+ "github.com/stretchr/testify/require"
34
35
"google.golang.org/grpc/codes"
35
36
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
36
37
"k8s.io/apimachinery/pkg/types"
@@ -670,7 +671,7 @@ func TestCreateRun_NullWorkflowSpec(t *testing.T) {
670
671
apiRun := & api.Run {
671
672
Name : "run1" ,
672
673
PipelineSpec : & api.PipelineSpec {
673
- WorkflowManifest : "null" , // this situation occurs for real when the manifest file disappears from object store in some way due to retention policy or manual deletion.
674
+ WorkflowManifest : "null" , // this situation occurs for real when the manifest file disappears from object store in some way due to retention policy or manual deletion.
674
675
Parameters : []* api.Parameter {
675
676
{Name : "param1" , Value : "world" },
676
677
},
@@ -1489,7 +1490,7 @@ func TestReportWorkflowResource_WorkflowMissingRunID(t *testing.T) {
1489
1490
defer store .Close ()
1490
1491
workflow := util .NewWorkflow (& v1alpha1.Workflow {
1491
1492
ObjectMeta : v1.ObjectMeta {
1492
- Name : run .Name ,
1493
+ Name : run .Name ,
1493
1494
},
1494
1495
})
1495
1496
err := manager .ReportWorkflowResource (workflow )
@@ -1519,6 +1520,24 @@ func TestReportWorkflowResource_WorkflowCompleted(t *testing.T) {
1519
1520
assert .Equal (t , wf .Labels [util .LabelKeyWorkflowPersistedFinalState ], "true" )
1520
1521
}
1521
1522
1523
+ func TestReportWorkflowResource_WorkflowCompleted_WorkflowNotFound (t * testing.T ) {
1524
+ store , manager , run := initWithOneTimeRun (t )
1525
+ defer store .Close ()
1526
+ workflow := util .NewWorkflow (& v1alpha1.Workflow {
1527
+ ObjectMeta : v1.ObjectMeta {
1528
+ Name : "non-existent-workflow" ,
1529
+ Namespace : "kubeflow" ,
1530
+ UID : types .UID (run .UUID ),
1531
+ Labels : map [string ]string {util .LabelKeyWorkflowRunId : run .UUID },
1532
+ },
1533
+ Status : v1alpha1.WorkflowStatus {Phase : v1alpha1 .NodeFailed },
1534
+ })
1535
+ err := manager .ReportWorkflowResource (workflow )
1536
+ require .NotNil (t , err )
1537
+ assert .Equalf (t , codes .NotFound , err .(* util.UserError ).ExternalStatusCode (), "Expected not found error, but got %s" , err .Error ())
1538
+ assert .Contains (t , err .Error (), "Failed to add PersistedFinalState label" )
1539
+ }
1540
+
1522
1541
func TestReportWorkflowResource_WorkflowCompleted_FinalStatePersisted (t * testing.T ) {
1523
1542
store , manager , run := initWithOneTimeRun (t )
1524
1543
defer store .Close ()
@@ -1536,6 +1555,24 @@ func TestReportWorkflowResource_WorkflowCompleted_FinalStatePersisted(t *testing
1536
1555
assert .Nil (t , err )
1537
1556
}
1538
1557
1558
+ func TestReportWorkflowResource_WorkflowCompleted_FinalStatePersisted_WorkflowNotFound (t * testing.T ) {
1559
+ store , manager , run := initWithOneTimeRun (t )
1560
+ defer store .Close ()
1561
+ workflow := util .NewWorkflow (& v1alpha1.Workflow {
1562
+ ObjectMeta : v1.ObjectMeta {
1563
+ Name : "non-existent-workflow" ,
1564
+ Namespace : "kubeflow" ,
1565
+ UID : types .UID (run .UUID ),
1566
+ Labels : map [string ]string {util .LabelKeyWorkflowRunId : run .UUID , util .LabelKeyWorkflowPersistedFinalState : "true" },
1567
+ },
1568
+ Status : v1alpha1.WorkflowStatus {Phase : v1alpha1 .NodeFailed },
1569
+ })
1570
+ err := manager .ReportWorkflowResource (workflow )
1571
+ require .NotNil (t , err )
1572
+ assert .Equalf (t , codes .NotFound , err .(* util.UserError ).ExternalStatusCode (), "Expected not found error, but got %s" , err .Error ())
1573
+ assert .Contains (t , err .Error (), "Failed to delete the completed workflow" )
1574
+ }
1575
+
1539
1576
func TestReportWorkflowResource_WorkflowCompleted_FinalStatePersisted_DeleteFailed (t * testing.T ) {
1540
1577
store , manager , run := initWithOneTimeRun (t )
1541
1578
manager .argoClient = client .NewFakeArgoClientWithBadWorkflow ()
0 commit comments