Skip to content

Commit

Permalink
investigate workflow config deployer schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed Oct 27, 2023
1 parent b136c2a commit 2e8b44d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 78 deletions.
38 changes: 0 additions & 38 deletions internal/step/plugin/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,44 +84,6 @@ type Plugin struct {
Type string
}

//func (p *pluginProvider) ProviderSchema() *schema.TypedScopeSchema[*Plugin] {
// return schema.NewTypedScopeSchema[*Plugin](
// schema.NewStructMappedObjectSchema[*Plugin](
// "Plugin",
// map[string]*schema.PropertySchema{
// "src": schema.NewPropertySchema(
// schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
// schema.NewDisplayValue(
// schema.PointerTo("Source"),
// schema.PointerTo("Source file to be executed."), nil),
// true,
// nil,
// nil,
// nil,
// nil,
// []string{"\"quay.io/arcaflow/example-plugin:latest\""},
// ),
// "type": schema.NewPropertySchema(
// schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
// schema.NewDisplayValue(
// schema.PointerTo("Type"),
// schema.PointerTo(
// fmt.Sprintf("Deployment type %s",
// fmt.Sprintf(KeysString(DeploymentTypes)))),
// nil,
// ),
// true,
// nil,
// nil,
// nil,
// nil,
// []string{"docker"},
// ),
// },
// ),
// )
//}

func (p *pluginProvider) ProviderSchema() map[string]*schema.PropertySchema {
return map[string]*schema.PropertySchema{
"src": schema.NewPropertySchema(
Expand Down
88 changes: 48 additions & 40 deletions internal/step/plugin/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ func TestProvider_MultipleDeployers(t *testing.T) {
"deploy_time": deployTimeMs,
"deploy_succeed": true,
},
"python": map[string]any{"type": "test-impl"},
"python": map[string]any{
"type": "test-impl",
},
}

plp, err := plugin.New(
Expand Down Expand Up @@ -395,6 +397,12 @@ func TestProvider_DeployFail(t *testing.T) {
"deploy_succeed": true,
}

_ := map[string]any{

Check failure on line 400 in internal/step/plugin/provider_test.go

View workflow job for this annotation

GitHub Actions / go test

no new variables on left side of :=
"type": "test-impl",
"deploy_time": deployTimeMs,
"deploy_succeed": true,
}

plp, err := plugin.New(
logger,
deployerRegistry,
Expand All @@ -409,47 +417,47 @@ func TestProvider_DeployFail(t *testing.T) {
}
byteSchema := map[string][]byte{}

runnable, err := plp.LoadSchema(stepSchema, byteSchema)
_, err = plp.LoadSchema(stepSchema, byteSchema)
assert.NoError(t, err)

handler := &deployFailStageChangeHandler{
message: make(chan string),
}

// wait step
running, err := runnable.Start(map[string]any{"step": "wait"}, t.Name(), handler)
assert.NoError(t, err)

assert.NoError(t, running.ProvideStageInput(
string(plugin.StageIDDeploy),
map[string]any{
"deploy": map[string]any{
"type": "test-impl",
//"deploy_succeed": false,
//"deploy_time": deployTimeMs,
},
},
))

waitTimeMs := 50
assert.NoError(t, running.ProvideStageInput(
string(plugin.StageIDStarting),
map[string]any{"input": map[string]any{"wait_time_ms": waitTimeMs}},
))

message := <-handler.message
assert.Equals(t,
message,
fmt.Sprintf("intentional deployment fail after %d ms", deployTimeMs))

assert.Equals(t, string(running.State()),
string(step.RunningStepStateFinished))

assert.Equals(t, running.CurrentStage(), string(plugin.StageIDDeployFailed))

t.Cleanup(func() {
assert.NoError(t, running.Close())
})
//handler := &deployFailStageChangeHandler{
// message: make(chan string),
//}
//
//// wait step
//running, err := runnable.Start(map[string]any{"step": "wait"}, t.Name(), handler)
//assert.NoError(t, err)
//
////assert.NoError(t, running.ProvideStageInput(
//// string(plugin.StageIDDeploy),
//// map[string]any{
//// "deploy": map[string]any{
//// "type": "test-impl",
//// //"deploy_succeed": false,
//// //"deploy_time": deployTimeMs,
//// },
//// },
////))
////
////waitTimeMs := 50
////assert.NoError(t, running.ProvideStageInput(
//// string(plugin.StageIDStarting),
//// map[string]any{"input": map[string]any{"wait_time_ms": waitTimeMs}},
////))
////
////message := <-handler.message
////assert.Equals(t,
//// message,
//// fmt.Sprintf("intentional deployment fail after %d ms", deployTimeMs))
////
////assert.Equals(t, string(running.State()),
//// string(step.RunningStepStateFinished))
////
////assert.Equals(t, running.CurrentStage(), string(plugin.StageIDDeployFailed))
////
////t.Cleanup(func() {
//// assert.NoError(t, running.Close())
////})
}

func TestProvider_StartFail(t *testing.T) {
Expand Down

0 comments on commit 2e8b44d

Please sign in to comment.