Skip to content

Commit

Permalink
unit test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Sep 26, 2017
1 parent fee6e2f commit d94ceaf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pkg/build/builder/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strconv"
"strings"

//"github.com/google/cadvisor/container/crio"
crio "github.com/kubernetes-incubator/cri-o/client"
"github.com/google/cadvisor/container/crio"
crioclient "github.com/kubernetes-incubator/cri-o/client"

docker "github.com/fsouza/go-dockerclient"

Expand Down Expand Up @@ -79,7 +79,7 @@ func getContainerNetworkConfig() (string, string, error) {
return s2iapi.DockerNetworkModeContainerPrefix + id, "", nil
}

crioClient, err := crio.New("/var/run/crio.sock")
crioClient, err := crioclient.New(crio.CrioSocket)
if err != nil {
return "", "", err
}
Expand Down
14 changes: 8 additions & 6 deletions pkg/build/controller/strategy/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"strings"
"testing"

"github.com/google/cadvisor/container/crio"

"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -63,20 +65,20 @@ func TestDockerCreateBuildPod(t *testing.T) {
t.Errorf("Expected environment keys:\n%v\ngot keys\n%v", expectedKeys, gotKeys)
}

// the pod has 5 volumes but the git source secret is not mounted into the main container.
if len(container.VolumeMounts) != 4 {
t.Fatalf("Expected 4 volumes in container, got %d", len(container.VolumeMounts))
// the pod has 6 volumes but the git source secret is not mounted into the main container.
if len(container.VolumeMounts) != 5 {
t.Fatalf("Expected 5 volumes in container, got %d", len(container.VolumeMounts))
}
if *actual.Spec.ActiveDeadlineSeconds != 60 {
t.Errorf("Expected ActiveDeadlineSeconds 60, got %d", *actual.Spec.ActiveDeadlineSeconds)
}
for i, expected := range []string{buildutil.BuildWorkDirMount, dockerSocketPath, DockerPushSecretMountPath, DockerPullSecretMountPath} {
for i, expected := range []string{buildutil.BuildWorkDirMount, dockerSocketPath, crio.CrioSocket, DockerPushSecretMountPath, DockerPullSecretMountPath} {
if container.VolumeMounts[i].MountPath != expected {
t.Fatalf("Expected %s in VolumeMount[%d], got %s", expected, i, container.VolumeMounts[i].MountPath)
}
}
if len(actual.Spec.Volumes) != 5 {
t.Fatalf("Expected 5 volumes in Build pod, got %d", len(actual.Spec.Volumes))
if len(actual.Spec.Volumes) != 6 {
t.Fatalf("Expected 6 volumes in Build pod, got %d", len(actual.Spec.Volumes))
}
if !kapihelper.Semantic.DeepEqual(container.Resources, util.CopyApiResourcesToV1Resources(&build.Spec.Resources)) {
t.Fatalf("Expected actual=expected, %v != %v", container.Resources, build.Spec.Resources)
Expand Down
14 changes: 8 additions & 6 deletions pkg/build/controller/strategy/sti_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"testing"

"github.com/google/cadvisor/container/crio"

"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -98,17 +100,17 @@ func testSTICreateBuildPod(t *testing.T, rootAllowed bool) {
t.Errorf("Expected environment keys:\n%v\ngot keys\n%v", expectedKeys, gotKeys)
}

// the pod has 5 volumes but the git source secret is not mounted into the main container.
if len(container.VolumeMounts) != 4 {
t.Fatalf("Expected 4 volumes in container, got %d", len(container.VolumeMounts))
// the pod has 6 volumes but the git source secret is not mounted into the main container.
if len(container.VolumeMounts) != 5 {
t.Fatalf("Expected 5 volumes in container, got %d", len(container.VolumeMounts))
}
for i, expected := range []string{buildutil.BuildWorkDirMount, dockerSocketPath, DockerPushSecretMountPath, DockerPullSecretMountPath} {
for i, expected := range []string{buildutil.BuildWorkDirMount, dockerSocketPath, crio.CrioSocket, DockerPushSecretMountPath, DockerPullSecretMountPath} {
if container.VolumeMounts[i].MountPath != expected {
t.Fatalf("Expected %s in VolumeMount[%d], got %s", expected, i, container.VolumeMounts[i].MountPath)
}
}
if len(actual.Spec.Volumes) != 5 {
t.Fatalf("Expected 5 volumes in Build pod, got %d", len(actual.Spec.Volumes))
if len(actual.Spec.Volumes) != 6 {
t.Fatalf("Expected 6 volumes in Build pod, got %d", len(actual.Spec.Volumes))
}
if *actual.Spec.ActiveDeadlineSeconds != 60 {
t.Errorf("Expected ActiveDeadlineSeconds 60, got %d", *actual.Spec.ActiveDeadlineSeconds)
Expand Down

0 comments on commit d94ceaf

Please sign in to comment.