Skip to content

Commit

Permalink
try extra interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisKujawa committed Nov 18, 2022
1 parent cb0f729 commit d4cfdc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go-chaos/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Defaults to the later, which is useful for experimenting with deployment distrib

if len(processModelPath) == 0 {
// deploy multi version
err := internal.DeployDifferentVersions(zbClient, int32(multipleVersions))
err := internal.DeployDifferentVersions(zbClient.NewDeployResourceCommand(), int32(multipleVersions))
if err != nil {
panic(err.Error())
}
Expand Down
16 changes: 11 additions & 5 deletions go-chaos/internal/zeebe.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,22 @@ func readModels(bpmnFileName string, dmnFileName string) (*models, error) {
return &models{bpmnBytes: bpmnBytes, dmnBytes: dmnBytes, bpmnFileName: bpmnFileName, dmnFileName: dmnFileName}, nil
}

func deployModels(client zbc.Client, models *models) error {
func deployModels(deployer Deployer, models *models) error {
_, err :=
client.NewDeployResourceCommand().AddResource(models.bpmnBytes, models.bpmnFileName).AddResource(models.dmnBytes, models.dmnFileName).Send(context.TODO())
deployer.AddResource(models.bpmnBytes, models.bpmnFileName).AddResource(models.dmnBytes, models.dmnFileName).Send(context.TODO())
if err != nil {
return err
}
return nil
}

func DeployDifferentVersions(client zbc.Client, versions int32) error {
type Deployer interface {
AddResource(definition []byte, name string) *Deployer
Send(ctx context.Context) (*pb.DeployResourceResponse, error)
}


func DeployDifferentVersions(deployer Deployer, versions int32) error {
firstModel, err := readModels("bpmn/multi-version/multiVersionModel.bpmn", "bpmn/multi-version/fancyDecision.dmn")
if err != nil {
return err
Expand All @@ -216,12 +222,12 @@ func DeployDifferentVersions(client zbc.Client, versions int32) error {

count := int32(0)
for count < versions {
err := deployModels(client, firstModel)
err := deployModels(deployer, firstModel)
if err != nil {
return err
}

err = deployModels(client, secondModel)
err = deployModels(deployer, secondModel)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions go-chaos/internal/zeebe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func Test_ShouldReadGivenFile(t *testing.T) {
}



func Test_ShouldDeployDefaultCountOfModels(t *testing.T) {
// given
client := CreateFakeZeebeClient()
Expand Down

0 comments on commit d4cfdc4

Please sign in to comment.