Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Evan <chaol@vmware.com>
  • Loading branch information
evanchaoli committed Jul 26, 2022
1 parent 7dd2088 commit 6a9cb53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 9 additions & 7 deletions atc/exec/check_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("CheckStep", func() {
checkPlan atc.CheckPlan
containerMetadata db.ContainerMetadata

strategy worker.PlacementStrategy
noInputStrategy, checkStrategy worker.PlacementStrategy

stepOk bool
stepErr error
Expand Down Expand Up @@ -140,8 +140,9 @@ var _ = Describe("CheckStep", func() {
}

var err error
strategy, _, err = worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{},
_, noInputStrategy, checkStrategy, err = worker.NewPlacementStrategy(worker.PlacementOptions{
NoInputStrategies: []string{},
CheckStrategies: []string{},
})
Expect(err).ToNot(HaveOccurred())
})
Expand All @@ -157,7 +158,8 @@ var _ = Describe("CheckStep", func() {
stepMetadata,
fakeResourceConfigFactory,
containerMetadata,
strategy,
noInputStrategy,
checkStrategy,
fakePool,
fakeDelegateFactory,
defaultTimeout,
Expand Down Expand Up @@ -449,9 +451,9 @@ var _ = Describe("CheckStep", func() {
fakePool.FindOrSelectWorkerReturns(chosenWorker, nil)
})

It("should use nil(random) strategy", func() {
It("should use check strategy", func() {
_, _, _, _, expectedStrategy, _ := fakePool.FindOrSelectWorkerArgsForCall(0)
Expect(expectedStrategy).To(BeNil())
Expect(expectedStrategy).To(Equal(checkStrategy))
})

It("points the resource or resource type to the scope", func() {
Expand Down Expand Up @@ -501,7 +503,7 @@ var _ = Describe("CheckStep", func() {

It("should use specified strategy", func() {
_, _, _, _, expectedStrategy, _ := fakePool.FindOrSelectWorkerArgsForCall(0)
Expect(expectedStrategy).To(Equal(strategy))
Expect(expectedStrategy).To(Equal(noInputStrategy))
})

It("points the resource or resource type to the scope", func() {
Expand Down
10 changes: 5 additions & 5 deletions atc/worker/placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var _ = Describe("Container Placement Strategies", func() {
Describe("Volume Locality", func() {
volumeLocalityStrategy := func() worker.PlacementStrategy {
strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"volume-locality"},
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -469,7 +469,7 @@ var _ = Describe("Container Placement Strategies", func() {

Describe("Fewest Build Containers", func() {
fewestBuildContainersStrategy := func() worker.PlacementStrategy {
strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"fewest-build-containers"},
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -505,7 +505,7 @@ var _ = Describe("Container Placement Strategies", func() {

Describe("Limit Active Tasks", func() {
limitActiveTasksStrategy := func(max int) worker.PlacementStrategy {
strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"limit-active-tasks"},
MaxActiveTasksPerWorker: max,
})
Expand Down Expand Up @@ -582,7 +582,7 @@ var _ = Describe("Container Placement Strategies", func() {

Describe("Limit Active Containers", func() {
limitActiveContainersStrategy := func(max int) worker.PlacementStrategy {
strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"limit-active-containers"},
MaxActiveContainersPerWorker: max,
})
Expand Down Expand Up @@ -670,7 +670,7 @@ var _ = Describe("Container Placement Strategies", func() {

Describe("Limit Active Volumes", func() {
limitActiveVolumesStrategy := func(max int) worker.PlacementStrategy {
strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"limit-active-volumes"},
MaxActiveVolumesPerWorker: max,
})
Expand Down
4 changes: 2 additions & 2 deletions atc/worker/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = Describe("Pool", func() {
),
)

strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"fewest-build-containers"},
})
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -268,7 +268,7 @@ var _ = Describe("Pool", func() {
),
)

strategy, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
strategy, _, _, err := worker.NewPlacementStrategy(worker.PlacementOptions{
Strategies: []string{"limit-active-tasks"},
MaxActiveTasksPerWorker: 1,
})
Expand Down

0 comments on commit 6a9cb53

Please sign in to comment.