-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] disable empty aggregator roles
...to avoid failed environment deployments due to missing status update
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package workflow | ||
|
||
import ( | ||
"github.com/AliceO2Group/Control/core/repos" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("aggregator role", func() { | ||
var _ = Describe("processing templates", func() { | ||
var root Role | ||
var repo repos.Repo | ||
var configStack map[string]string | ||
|
||
BeforeEach(func() { | ||
_, repo, _ = repos.NewRepo("/home/user/git/ControlWorkflows", "", "/var/lib/o2/aliecs/repos") | ||
configStack = make(map[string]string) | ||
}) | ||
|
||
When("an aggregator role is empty", func() { | ||
BeforeEach(func() { | ||
root = &aggregatorRole{ | ||
roleBase{Name: "root", Enabled: "true"}, | ||
aggregator{Roles: []Role{}}, | ||
} | ||
}) | ||
It("should disable itself", func() { | ||
Expect(root.IsEnabled()).To(BeTrue()) | ||
err := root.ProcessTemplates(&repo, nil, configStack) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(root.IsEnabled()).To(BeFalse()) | ||
}) | ||
}) | ||
|
||
When("an aggregator role has only disabled sub-roles", func() { | ||
BeforeEach(func() { | ||
root = &aggregatorRole{ | ||
roleBase{Name: "root", Enabled: "true"}, | ||
aggregator{ | ||
Roles: []Role{&taskRole{roleBase: roleBase{Name: "task1", Enabled: "false"}}}, | ||
}, | ||
} | ||
}) | ||
It("remove the disabled roles and disable itself", func() { | ||
Expect(root.IsEnabled()).To(BeTrue()) | ||
err := root.ProcessTemplates(&repo, nil, configStack) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(root.IsEnabled()).To(BeFalse()) | ||
Expect(root.GetRoles()).Should(BeEmpty()) | ||
}) | ||
}) | ||
|
||
When("an aggregator role has an enabled role", func() { | ||
BeforeEach(func() { | ||
root = &aggregatorRole{ | ||
roleBase{Name: "root", Enabled: "true"}, | ||
aggregator{ | ||
Roles: []Role{&taskRole{roleBase: roleBase{Name: "task1", Enabled: "true"}}}, | ||
}, | ||
} | ||
}) | ||
It("should be enabled", func() { | ||
Expect(root.IsEnabled()).To(BeTrue()) | ||
err := root.ProcessTemplates(&repo, nil, configStack) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(root.IsEnabled()).To(BeTrue()) | ||
Expect(root.GetRoles()).ShouldNot(BeEmpty()) | ||
}) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters