From 9255c19786177c643820ce01c379485cc345df6c Mon Sep 17 00:00:00 2001 From: Matthew F Leader Date: Mon, 20 Nov 2023 16:50:51 -0500 Subject: [PATCH 1/4] add test --- internal/step/plugin/provider_test.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/step/plugin/provider_test.go b/internal/step/plugin/provider_test.go index 6858b002..97669f4d 100644 --- a/internal/step/plugin/provider_test.go +++ b/internal/step/plugin/provider_test.go @@ -10,6 +10,7 @@ import ( "go.flow.arcalot.io/engine/internal/step" "go.flow.arcalot.io/engine/internal/step/plugin" testdeployer "go.flow.arcalot.io/testdeployer" + stubdeployer "go.flow.arcalot.io/testdeployer/stub" "sync" "testing" ) @@ -252,20 +253,27 @@ func TestProvider_HappyError(t *testing.T) { workflowDeployerCfg := map[string]any{ "builtin": map[string]any{ "deployer_name": "test-impl"}, + "test-double": map[string]any{ + "deployer_name": "test-stub", + }, } deployerRegistry := deployer_registry.New( - deployer.Any(testdeployer.NewFactory())) + deployer.Any(testdeployer.NewFactory()), + deployer.Any(stubdeployer.NewFactory())) + // Deployer type not in deployer registry _, err := plugin.New(logger, deployerRegistry, map[string]any{ "wrong": map[string]any{ "deployer_name": "test-impl", }}) assert.Error(t, err) + // Deployment type test-double is in deployer registry, but does not + // match the deployment type for test-impl _, err = plugin.New(logger, deployerRegistry, map[string]any{ - "builtin": map[string]any{ - "deployer_name": "bad", + "test-double": map[string]any{ + "deployer_name": "test-impl", }}) assert.Error(t, err) @@ -298,6 +306,14 @@ func TestProvider_HappyError(t *testing.T) { assert.Error(t, running.ProvideStageInput( "", nil)) + // deployer name and deployment type mismatch + assert.Error(t, running.ProvideStageInput( + string(plugin.StageIDDeploy), + map[string]any{"deploy": map[string]any{ + "deployer_name": "test-stub", + "deploy_time": 1}}, + )) + // unserialize malformed deploy schema assert.Error(t, running.ProvideStageInput( string(plugin.StageIDDeploy), From d95d9ad083e4a06d36e2c92669ca8fc133d1cb90 Mon Sep 17 00:00:00 2001 From: Matthew F Leader Date: Mon, 20 Nov 2023 16:52:41 -0500 Subject: [PATCH 2/4] remove redundant tests --- internal/step/plugin/provider_test.go | 72 --------------------------- 1 file changed, 72 deletions(-) diff --git a/internal/step/plugin/provider_test.go b/internal/step/plugin/provider_test.go index 97669f4d..d5677085 100644 --- a/internal/step/plugin/provider_test.go +++ b/internal/step/plugin/provider_test.go @@ -6,7 +6,6 @@ import ( "go.arcalot.io/log/v2" "go.flow.arcalot.io/deployer" deployer_registry "go.flow.arcalot.io/deployer/registry" - docker "go.flow.arcalot.io/dockerdeployer" "go.flow.arcalot.io/engine/internal/step" "go.flow.arcalot.io/engine/internal/step/plugin" testdeployer "go.flow.arcalot.io/testdeployer" @@ -112,59 +111,6 @@ func (s *stageChangeHandler) OnStepComplete( s.message <- message } -func TestProvider_MultipleDeployers(t *testing.T) { - logger := log.New( - log.Config{ - Level: log.LevelError, - Destination: log.DestinationStdout, - }, - ) - deployerRegistry := deployer_registry.New( - deployer.Any(testdeployer.NewFactory()), - deployer.Any(docker.NewFactory())) - deployTimeMs := 20 - workflowDeployerCfg := map[string]any{ - "builtin": map[string]any{ - "deployer_name": "test-impl", - "deploy_time": deployTimeMs, - "deploy_succeed": true, - }, - "image": map[string]any{ - "deployer_name": "docker", - }, - } - - plp, err := plugin.New(logger, deployerRegistry, workflowDeployerCfg) - assert.NoError(t, err) - assert.Equals(t, plp.Kind(), "plugin") - assert.NotNil(t, plp.ProviderSchema()) - assert.NotNil(t, plp.RunProperties()) - assert.NotNil(t, plp.Lifecycle()) - - stepSchema := map[string]any{ - "plugin": map[string]any{ - "src": "simulation", - "deployment_type": "builtin", - }, - } - byteSchema := map[string][]byte{} - - runnable, err := plp.LoadSchema(stepSchema, byteSchema) - assert.NoError(t, err) - - assert.NotNil(t, runnable.RunSchema()) - - _, err = runnable.Lifecycle(map[string]any{"step": "wait"}) - assert.NoError(t, err) - - _, err = runnable.Lifecycle(map[string]any{"step": "hello"}) - assert.NoError(t, err) - - // There is more than one step, so no specified one will cause an error. - _, err = runnable.Lifecycle(map[string]any{"step": nil}) - assert.Error(t, err) -} - func TestProvider_MissingDeployer(t *testing.T) { logger := log.New( log.Config{ @@ -182,24 +128,6 @@ func TestProvider_MissingDeployer(t *testing.T) { _, err := plugin.New(logger, deployerRegistry, workflowDeployerCfg) assert.Error(t, err) } -func TestProvider_MismatchedDeploymentTypes(t *testing.T) { - logger := log.New( - log.Config{ - Level: log.LevelError, - Destination: log.DestinationStdout, - }, - ) - deployerRegistry := deployer_registry.New(deployer.Any(testdeployer.NewFactory())) - // Mismatched. test-impl is has the deployment type builtin, but we're trying to specify it for the image type. - workflowDeployerCfg := map[string]any{ - "image": map[string]any{ - "deployer_name": "test-impl", - }, - } - - _, err := plugin.New(logger, deployerRegistry, workflowDeployerCfg) - assert.Error(t, err) -} func TestProvider_Utility(t *testing.T) { workflowDeployerCfg := map[string]any{ From c254d9f8c5f4897111d68743bffe5a68accf25cf Mon Sep 17 00:00:00 2001 From: Matthew F Leader Date: Tue, 21 Nov 2023 16:30:11 -0500 Subject: [PATCH 3/4] change stub deployment type --- internal/step/plugin/provider_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/step/plugin/provider_test.go b/internal/step/plugin/provider_test.go index d5677085..e695355f 100644 --- a/internal/step/plugin/provider_test.go +++ b/internal/step/plugin/provider_test.go @@ -181,7 +181,7 @@ func TestProvider_HappyError(t *testing.T) { workflowDeployerCfg := map[string]any{ "builtin": map[string]any{ "deployer_name": "test-impl"}, - "test-double": map[string]any{ + "stubby": map[string]any{ "deployer_name": "test-stub", }, } @@ -197,10 +197,10 @@ func TestProvider_HappyError(t *testing.T) { }}) assert.Error(t, err) - // Deployment type test-double is in deployer registry, but does not + // Deployment type stubby is in deployer registry, but does not // match the deployment type for test-impl _, err = plugin.New(logger, deployerRegistry, map[string]any{ - "test-double": map[string]any{ + "stubby": map[string]any{ "deployer_name": "test-impl", }}) assert.Error(t, err) From 10fac260e7cb6a14e3004690fb51f2a61318d50d Mon Sep 17 00:00:00 2001 From: Matthew F Leader Date: Tue, 21 Nov 2023 16:41:01 -0500 Subject: [PATCH 4/4] update deployer double dep --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index af4cbf3a..9ad03b04 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( go.flow.arcalot.io/pluginsdk v0.5.1 go.flow.arcalot.io/podmandeployer v0.6.2 go.flow.arcalot.io/pythondeployer v0.4.0 - go.flow.arcalot.io/testdeployer v0.4.0 + go.flow.arcalot.io/testdeployer v0.5.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 0b9337fc..c8620a6f 100644 --- a/go.sum +++ b/go.sum @@ -170,14 +170,12 @@ go.flow.arcalot.io/kubernetesdeployer v0.8.0 h1:UjH/aspPif/k+X65sLWlNDZAW5JlzUfg go.flow.arcalot.io/kubernetesdeployer v0.8.0/go.mod h1:BhERhKpvQMJkrcW9lbBF4kJEe+OGhz2NpSftZIgtVNQ= go.flow.arcalot.io/pluginsdk v0.5.1 h1:ebb2ThAqmjmwGpDyKpd1wEDUisPqPabgARjFohy47Io= go.flow.arcalot.io/pluginsdk v0.5.1/go.mod h1:2s2f//7uOkBjr1QaiWJD/bqDIeLlINJtD1BhiY4aGPM= -go.flow.arcalot.io/podmandeployer v0.6.1 h1:NPSQ82PyvxTRDsHuLj6oBhPUlhVVqPlnXWkElF2PcT8= -go.flow.arcalot.io/podmandeployer v0.6.1/go.mod h1:4wfcl0qjV02y64We3ZSDz+3lwdOfbe+gpFjm7SQKTRA= go.flow.arcalot.io/podmandeployer v0.6.2 h1:iAAZGgwhxInEVAleakavGruHnW4qsD/v39JpfnTeXiE= go.flow.arcalot.io/podmandeployer v0.6.2/go.mod h1:BmKbyG2qZG9PMPLkIeXUvKVJfU+AZx+POLvydZN26IY= go.flow.arcalot.io/pythondeployer v0.4.0 h1:l8nw6awYMVzgND+ZXdbnNJPYu3V0sgSUFsIzn+SRgh0= go.flow.arcalot.io/pythondeployer v0.4.0/go.mod h1:me9SIMVTCBzCmceILdBMxXYrZGakiPOMasHgujmgJlE= -go.flow.arcalot.io/testdeployer v0.4.0 h1:helexgZOnYlbzU+egkxsLs95iMwE3lc+vp+Qbv2xwFI= -go.flow.arcalot.io/testdeployer v0.4.0/go.mod h1:Luw76oKeri40a7k8buk7Q7J86Tpt8lf9LTVZr6lqgTk= +go.flow.arcalot.io/testdeployer v0.5.0 h1:kS/nCQuqGNpkILG5QwtalE59mefuePdTaol95mSUMRQ= +go.flow.arcalot.io/testdeployer v0.5.0/go.mod h1:W8u5VACtmfto3yCYO1D/YQNsV8tivx4MaxehcXdsXGU= go.flow.arcalot.io/testplugin v0.3.0 h1:LY0VWL1M0X+mSE0nVCwoD0PjQHqKhbka2Gc70uuP04k= go.flow.arcalot.io/testplugin v0.3.0/go.mod h1:TW6h/kZyM+4gBBKqvoDI0XWXgNcUMKbDHaQOaKIRZdk= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=