Skip to content

Commit

Permalink
Fix install tests and build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Mar 7, 2018
1 parent 06c0d32 commit dcdf9ac
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
PACKR_CMD=$(shell if [ -f "vendor/github.com/gobuffalo/packr/packr/main.go" ]; then echo "go run vendor/github.com/gobuffalo/packr/packr/main.go"; else echo "go run /root/go/src/github.com/gobuffalo/packr/packr/main.go"; fi)

BUILDER_IMAGE=argo-builder
# NOTE: the volume mount of ${DIST_DIR}/pkg below is optional and serves only
Expand Down Expand Up @@ -58,7 +59,7 @@ builder:

.PHONY: cli
cli:
CGO_ENABLED=0 go run vendor/github.com/gobuffalo/packr/packr/main.go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${ARGO_CLI_NAME} ./cmd/argo
CGO_ENABLED=0 ${PACKR_CMD} build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${ARGO_CLI_NAME} ./cmd/argo

.PHONY: cli-linux
cli-linux: builder
Expand Down
24 changes: 14 additions & 10 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package e2e
import (
"flag"

"github.com/argoproj/argo/cmd/argo/commands"
"github.com/argoproj/argo/install"
"github.com/argoproj/argo/workflow/common"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
// load the gcp plugin (required to authenticate against GKE clusters).
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
)

var kubeConfig = flag.String("kubeconfig", "", "Path to Kubernetes config file")

func getKubernetesClient() *kubernetes.Clientset {
func getKubernetesClient() (*rest.Config, *kubernetes.Clientset) {
if *kubeConfig == "" {
panic("Kubeconfig not provided")
}
Expand All @@ -32,13 +33,11 @@ func getKubernetesClient() *kubernetes.Clientset {
panic(err.Error())
}

return clientSet
return config, clientSet
}

func newInstallArgs(namespace string) commands.InstallFlags {
return commands.InstallFlags{
ControllerName: common.DefaultControllerDeploymentName,
UIName: commands.ArgoUIDeploymentName,
func newInstallArgs(namespace string) install.InstallOptions {
return install.InstallOptions{
Namespace: namespace,
ConfigMap: common.DefaultConfigMapName(common.DefaultControllerDeploymentName),
ControllerImage: "argoproj/workflow-controller:latest",
Expand All @@ -49,7 +48,7 @@ func newInstallArgs(namespace string) commands.InstallFlags {
}

func createNamespaceForTest() string {
clientset := getKubernetesClient()
_, clientset := getKubernetesClient()
ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "argo-e2e-test-",
Expand All @@ -64,12 +63,17 @@ func createNamespaceForTest() string {
}

func deleteTestNamespace(namespace string) error {
clientset := getKubernetesClient()
_, clientset := getKubernetesClient()
deleteOptions := metav1.DeleteOptions{}
return clientset.CoreV1().Namespaces().Delete(namespace, &deleteOptions)
}

func installArgoInNamespace(namespace string) {
args := newInstallArgs(namespace)
commands.Install(args)
config, _ := getKubernetesClient()
installer, err := install.NewInstaller(config, args)
if err != nil {
panic(err)
}
installer.Install()
}
11 changes: 8 additions & 3 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/argoproj/argo/cmd/argo/commands"
"github.com/argoproj/argo/install"
"github.com/argoproj/argo/workflow/common"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -37,7 +37,7 @@ func (suite *InstallSuite) TearDownTest() {
}

func checkIfInstalled(namespace string) bool {
clientSet := getKubernetesClient()
_, clientSet := getKubernetesClient()

// Verify that Argo doesn't exist in the Kube-system namespace
_, err := clientSet.AppsV1beta2().Deployments(namespace).Get(
Expand All @@ -62,7 +62,12 @@ func (suite *InstallSuite) TestInstall() {
// Verify --dry-run doesn't install
args := newInstallArgs(suite.testNamespace)
args.DryRun = true
commands.Install(args)
config, _ := getKubernetesClient()
installer, err := install.NewInstaller(config, args)
if err != nil {
panic(err)
}
installer.Install()
assert.Equal(t, false, checkIfInstalled(suite.testNamespace))

installArgoInNamespace(suite.testNamespace)
Expand Down

0 comments on commit dcdf9ac

Please sign in to comment.