Merge pull request #25584 from jayunit100/kill-repo-root-slb

Automatic merge from submit-queue

2nd iteration of Gobindata + RepoRoot removals.

Part of my overall life mission to kill reporoot.

Fixes part of #24348

cc @kubernetes/sig-testing .
pull/6/head
k8s-merge-robot 2016-07-29 15:07:44 -07:00 committed by GitHub
commit df0d5826f5
13 changed files with 2114 additions and 5512 deletions

2
.gitignore vendored
View File

@ -104,3 +104,5 @@ kubernetes.tar.gz
# make-related metadata # make-related metadata
/.make/ /.make/
# Just in time generated data in the source, should never be commited
/test/e2e/generated/bindata.go

View File

@ -48,6 +48,7 @@ kube::golang::server_targets() {
fi fi
echo "${targets[@]}" echo "${targets[@]}"
} }
readonly KUBE_SERVER_TARGETS=($(kube::golang::server_targets)) readonly KUBE_SERVER_TARGETS=($(kube::golang::server_targets))
readonly KUBE_SERVER_BINARIES=("${KUBE_SERVER_TARGETS[@]##*/}") readonly KUBE_SERVER_BINARIES=("${KUBE_SERVER_TARGETS[@]##*/}")
@ -454,6 +455,7 @@ kube::golang::build_binaries_for_platform() {
local -a statics=() local -a statics=()
local -a nonstatics=() local -a nonstatics=()
local -a tests=() local -a tests=()
for binary in "${binaries[@]}"; do for binary in "${binaries[@]}"; do
# TODO(IBM): Enable hyperkube builds for ppc64le again # TODO(IBM): Enable hyperkube builds for ppc64le again
@ -610,6 +612,18 @@ kube::golang::build_binaries() {
local use_go_build local use_go_build
local -a targets=() local -a targets=()
local arg local arg
# Add any files with those //generate annotations in the array below.
readonly BINDATAS=( "${KUBE_ROOT}/test/e2e/framework/gobindata_util.go" )
kube::log::status "Generating bindata:" "${BINDATAS[@]}"
for bindata in ${BINDATAS[@]}; do
# Only try to generate bindata if the file exists, since in some cases
# one-off builds of individual directories may exclude some files.
if [[ -f $bindata ]]; then
go generate "${bindata}"
fi
done
for arg; do for arg; do
if [[ "${arg}" == "--use_go_build" ]]; then if [[ "${arg}" == "--use_go_build" ]]; then
use_go_build=true use_go_build=true

File diff suppressed because it is too large Load Diff

59
hack/update-bindata.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o pipefail
if [[ -z ${KUBE_ROOT} ]]; then
echo "KUBE_ROOT not detected, setting default."
KUBE_ROOT="../../../"
fi
set -o nounset
if [[ ! -d "${KUBE_ROOT}/examples" ]]; then
echo "${KUBE_ROOT}/examples not detected. This script should be run from a location where the source dirs are available."
exit 1
fi
# Setup bindata if not already in the system.
# For separation of concerns, download first, then install later.
if ! git config -l | grep -q "user.name" && ! git config -l | grep -q "user.email" ; then
git config --global user.name bindata-mockuser
git config --global user.email bindata-mockuser@example.com
fi
go get -u github.com/jteeuwen/go-bindata/... || echo "go-bindata get failed, possibly already exists, proceeding"
go install github.com/jteeuwen/go-bindata/... || echo "go-bindata install may have failed, proceeding anyway..."
if [[ ! -f ${GOPATH}/bin/go-bindata ]]; then
echo "missing bin/go-bindata"
echo "for debugging, printing search for bindata files out..."
find ${GOPATH} -name go-bindata
exit 5
fi
BINDATA_OUTPUT="${KUBE_ROOT}/test/e2e/generated/bindata.go"
${GOPATH}/bin/go-bindata -nometadata -prefix "${KUBE_ROOT}" -o ${BINDATA_OUTPUT} -pkg generated \
-ignore .jpg -ignore .png -ignore .md \
"${KUBE_ROOT}/examples/..." \
"${KUBE_ROOT}/docs/user-guide/..." \
"${KUBE_ROOT}/test/e2e/testing-manifests/..." \
"${KUBE_ROOT}/test/images/..."
gofmt -s -w ${BINDATA_OUTPUT}
echo "Generated bindata file : $(wc -l ${BINDATA_OUTPUT}) lines of lovely automated artifacts"

View File

@ -129,7 +129,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
if err := framework.WaitForPodsRunningReady(c, api.NamespaceSystem, int32(framework.TestContext.MinStartupPods), podStartupTimeout, framework.ImagePullerLabels); err != nil { if err := framework.WaitForPodsRunningReady(c, api.NamespaceSystem, int32(framework.TestContext.MinStartupPods), podStartupTimeout, framework.ImagePullerLabels); err != nil {
framework.DumpAllNamespaceInfo(c, api.NamespaceSystem) framework.DumpAllNamespaceInfo(c, api.NamespaceSystem)
framework.LogFailedContainers(c, api.NamespaceSystem) framework.LogFailedContainers(c, api.NamespaceSystem)
framework.RunKubernetesServiceTestContainer(c, framework.TestContext.RepoRoot, api.NamespaceDefault) framework.RunKubernetesServiceTestContainer(c, api.NamespaceDefault)
framework.Failf("Error waiting for all pods to be running and ready: %v", err) framework.Failf("Error waiting for all pods to be running and ready: %v", err)
} }

View File

@ -16,26 +16,17 @@ limitations under the License.
package framework package framework
//go:generate ../../../hack/update-bindata.sh
// See https://github.com/kubernetes/kubernetes/issues/23987
import "k8s.io/kubernetes/test/e2e/generated" import "k8s.io/kubernetes/test/e2e/generated"
/* /*
ReadOrDie reads a file from gobindata. To generate gobindata, run ReadOrDie reads a file from gobindata.
Relies heavily on the successful generation of build artifacts as per the go:generate directives above.
# Install the program
go get -u github.com/jteeuwen/go-bindata/...
# Generate the bindata file.
go-bindata \
-pkg generated -ignore .jpg -ignore .png -ignore .md \
./examples/* ./docs/user-guide/* test/e2e/testing-manifests/kubectl/* test/images/*
# Copy it into the generated directory if the results are what you expected.
cp bindata.go test/e2e/generated
# Don't forget to gofmt it
gofmt -s -w test/e2e/generated/bindata.go
*/ */
func ReadOrDie(filePath string) []byte { func ReadOrDie(filePath string) []byte {
fileBytes, err := generated.Asset(filePath) fileBytes, err := generated.Asset(filePath)
if err != nil { if err != nil {
gobindata_msg := "An error occured, possibly gobindata doesn't know about the file you're opening. For questions on maintaining gobindata, contact the sig-testing group." gobindata_msg := "An error occured, possibly gobindata doesn't know about the file you're opening. For questions on maintaining gobindata, contact the sig-testing group."

View File

@ -33,15 +33,16 @@ type TestContextType struct {
KubeVolumeDir string KubeVolumeDir string
CertDir string CertDir string
Host string Host string
RepoRoot string // TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
Provider string RepoRoot string
CloudConfig CloudConfig Provider string
KubectlPath string CloudConfig CloudConfig
OutputDir string KubectlPath string
ReportDir string OutputDir string
ReportPrefix string ReportDir string
Prefix string ReportPrefix string
MinStartupPods int Prefix string
MinStartupPods int
// Timeout for waiting for system pods to be running // Timeout for waiting for system pods to be running
SystemPodsStartupTimeout time.Duration SystemPodsStartupTimeout time.Duration
UpgradeTarget string UpgradeTarget string

View File

@ -21,7 +21,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math" "math"
"math/rand" "math/rand"
"net" "net"
@ -640,10 +639,7 @@ func WaitForPodsRunningReady(c *client.Client, ns string, minPods int32, timeout
func podFromManifest(filename string) (*api.Pod, error) { func podFromManifest(filename string) (*api.Pod, error) {
var pod api.Pod var pod api.Pod
Logf("Parsing pod from %v", filename) Logf("Parsing pod from %v", filename)
data, err := ioutil.ReadFile(filename) data := ReadOrDie(filename)
if err != nil {
return nil, err
}
json, err := utilyaml.ToJSON(data) json, err := utilyaml.ToJSON(data)
if err != nil { if err != nil {
return nil, err return nil, err
@ -656,8 +652,13 @@ func podFromManifest(filename string) (*api.Pod, error) {
// Run a test container to try and contact the Kubernetes api-server from a pod, wait for it // Run a test container to try and contact the Kubernetes api-server from a pod, wait for it
// to flip to Ready, log its output and delete it. // to flip to Ready, log its output and delete it.
func RunKubernetesServiceTestContainer(c *client.Client, repoRoot string, ns string) { func RunKubernetesServiceTestContainer(c *client.Client, ns string) {
path := filepath.Join(repoRoot, "test", "images", "clusterapi-tester", "pod.yaml") c, err := LoadClient()
if err != nil {
Logf("Failed to load client")
return
}
path := "test/images/clusterapi-tester/pod.yaml"
p, err := podFromManifest(path) p, err := podFromManifest(path)
if err != nil { if err != nil {
Logf("Failed to parse clusterapi-tester from manifest %v: %v", path, err) Logf("Failed to parse clusterapi-tester from manifest %v: %v", path, err)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,19 @@
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package generated
// No code is needed here. This is a stub for compilation purposes.

View File

@ -18,7 +18,6 @@ package e2e
import ( import (
"fmt" "fmt"
"path/filepath"
"time" "time"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
@ -697,8 +696,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
By("Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value.") By("Trying to launch a pod that with NodeAffinity setting as embedded JSON string in the annotation value.")
labelPodName := "with-labels" labelPodName := "with-labels"
nodeSelectionRoot := filepath.Join(framework.TestContext.RepoRoot, "test/e2e/testing-manifests/node-selection") testPodPath := string(framework.ReadOrDie("test/e2e/testing-manifests/node-selection/pod-with-node-affinity.yaml"))
testPodPath := filepath.Join(nodeSelectionRoot, "pod-with-node-affinity.yaml")
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns)) framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
// check that pod got scheduled. We intentionally DO NOT check that the // check that pod got scheduled. We intentionally DO NOT check that the
@ -1213,8 +1211,7 @@ var _ = framework.KubeDescribe("SchedulerPredicates [Serial]", func() {
By("Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value.") By("Trying to launch a pod that with PodAffinity & PodAntiAffinity setting as embedded JSON string in the annotation value.")
labelPodName := "with-newlabels" labelPodName := "with-newlabels"
nodeSelectionRoot := filepath.Join(framework.TestContext.RepoRoot, "test/e2e/testing-manifests/node-selection") testPodPath := string(framework.ReadOrDie("test/e2e/testing-manifests/node-selection/pos-with-node-affinity.yaml"))
testPodPath := filepath.Join(nodeSelectionRoot, "pod-with-pod-affinity.yaml")
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns)) framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
// check that pod got scheduled. We intentionally DO NOT check that the // check that pod got scheduled. We intentionally DO NOT check that the

View File

@ -20,7 +20,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"path/filepath"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
@ -35,23 +34,23 @@ import (
) )
// getLoadBalancerControllers returns a list of LBCtesters. // getLoadBalancerControllers returns a list of LBCtesters.
func getLoadBalancerControllers(repoRoot string, client *client.Client) []LBCTester { func getLoadBalancerControllers(client *client.Client) []LBCTester {
return []LBCTester{ return []LBCTester{
&haproxyControllerTester{ &haproxyControllerTester{
name: "haproxy", name: "haproxy",
cfg: filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "haproxyrc.yaml"), cfg: "test/e2e/testing-manifests/serviceloadbalancer/haproxyrc.yaml",
client: client, client: client,
}, },
} }
} }
// getIngManagers returns a list of ingManagers. // getIngManagers returns a list of ingManagers.
func getIngManagers(repoRoot string, client *client.Client) []*ingManager { func getIngManagers(client *client.Client) []*ingManager {
return []*ingManager{ return []*ingManager{
{ {
name: "netexec", name: "netexec",
rcCfgPaths: []string{filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "netexecrc.yaml")}, rcCfgPaths: []string{"test/e2e/testing-manifests/serviceloadbalancer/netexecrc.yaml"},
svcCfgPaths: []string{filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "netexecsvc.yaml")}, svcCfgPaths: []string{"test/e2e/testing-manifests/serviceloadbalancer/netexecsvc.yaml"},
svcNames: []string{}, svcNames: []string{},
client: client, client: client,
}, },
@ -208,7 +207,6 @@ func (s *ingManager) test(path string) error {
var _ = framework.KubeDescribe("ServiceLoadBalancer [Feature:ServiceLoadBalancer]", func() { var _ = framework.KubeDescribe("ServiceLoadBalancer [Feature:ServiceLoadBalancer]", func() {
// These variables are initialized after framework's beforeEach. // These variables are initialized after framework's beforeEach.
var ns string var ns string
var repoRoot string
var client *client.Client var client *client.Client
f := framework.NewDefaultFramework("servicelb") f := framework.NewDefaultFramework("servicelb")
@ -216,15 +214,14 @@ var _ = framework.KubeDescribe("ServiceLoadBalancer [Feature:ServiceLoadBalancer
BeforeEach(func() { BeforeEach(func() {
client = f.Client client = f.Client
ns = f.Namespace.Name ns = f.Namespace.Name
repoRoot = framework.TestContext.RepoRoot
}) })
It("should support simple GET on Ingress ips", func() { It("should support simple GET on Ingress ips", func() {
for _, t := range getLoadBalancerControllers(repoRoot, client) { for _, t := range getLoadBalancerControllers(client) {
By(fmt.Sprintf("Starting loadbalancer controller %v in namespace %v", t.getName(), ns)) By(fmt.Sprintf("Starting loadbalancer controller %v in namespace %v", t.getName(), ns))
Expect(t.start(ns)).NotTo(HaveOccurred()) Expect(t.start(ns)).NotTo(HaveOccurred())
for _, s := range getIngManagers(repoRoot, client) { for _, s := range getIngManagers(client) {
By(fmt.Sprintf("Starting ingress manager %v in namespace %v", s.getName(), ns)) By(fmt.Sprintf("Starting ingress manager %v in namespace %v", s.getName(), ns))
Expect(s.start(ns)).NotTo(HaveOccurred()) Expect(s.start(ns)).NotTo(HaveOccurred())
@ -268,8 +265,7 @@ func simpleGET(c *http.Client, url, host string) (string, error) {
func rcFromManifest(fileName string) *api.ReplicationController { func rcFromManifest(fileName string) *api.ReplicationController {
var controller api.ReplicationController var controller api.ReplicationController
framework.Logf("Parsing rc from %v", fileName) framework.Logf("Parsing rc from %v", fileName)
data, err := ioutil.ReadFile(fileName) data := framework.ReadOrDie(fileName)
Expect(err).NotTo(HaveOccurred())
json, err := utilyaml.ToJSON(data) json, err := utilyaml.ToJSON(data)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
@ -282,8 +278,7 @@ func rcFromManifest(fileName string) *api.ReplicationController {
func svcFromManifest(fileName string) *api.Service { func svcFromManifest(fileName string) *api.Service {
var svc api.Service var svc api.Service
framework.Logf("Parsing service from %v", fileName) framework.Logf("Parsing service from %v", fileName)
data, err := ioutil.ReadFile(fileName) data := framework.ReadOrDie(fileName)
Expect(err).NotTo(HaveOccurred())
json, err := utilyaml.ToJSON(data) json, err := utilyaml.ToJSON(data)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())

View File

@ -28,7 +28,16 @@ set -x
. $1 . $1
if [ "$INSTALL_GODEP" = true ] ; then
go get -u github.com/tools/godep
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/onsi/gomega
fi
make generated_files make generated_files
# TODO converge build steps with hack/build-go some day if possible.
go generate test/e2e/framework/gobindata_util.go
go build test/e2e_node/environment/conformance.go go build test/e2e_node/environment/conformance.go
WORKSPACE=${WORKSPACE:-"/tmp/"} WORKSPACE=${WORKSPACE:-"/tmp/"}