// MakeUnitChain creates the unit files of the benchmark units. func (b *Builder) MakeUnitChain(id string) []schema.Unit { unitsList := []schema.Unit{} // 3 dependsOn 2; 2 dependsOn 1; 1 dependsOn 0 // 0 after 1; 1 after 2 ; 2 after 3 for i := b.instanceGroupSize - 1; i >= 0; i-- { name := fmt.Sprintf("%s-%d@%s.service", b.unitPrefix, i, id) unit := schema.Unit{ Name: name, } if b.app.Type == "unitfiles" && b.unitFile != nil { unit.Options = b.buildCustomService() } else if b.app.Type == "docker" { unit.Options = b.buildDockerService() } else if b.app.Type == "rkt" { unit.Options = b.buildRktService() } else { unit.Options = b.buildShellService() } if i > 0 { depName := fmt.Sprintf("%s-%d@%s.service", b.unitPrefix, i-1, id) unit.Options = append(unit.Options, &schema.UnitOption{ Section: "X-Fleet", Name: "MachineOf", Value: depName, }, ) } unitsList = append(unitsList, unit) } if len(unitsList) > 1 { for i := 0; i < (len(unitsList) - 1); i++ { depName := unitsList[i+1].Name unitsList[i].Options = append(unitsList[i].Options, &schema.UnitOption{ Section: "Unit", Name: "Before", Value: depName, }, &schema.UnitOption{ Section: "Unit", Name: "BindTo", Value: depName, }, ) } } return unitsList }