Skip to content

Commit

Permalink
kill repo-root : test/e2e/serviceloadbalancers.go
Browse files Browse the repository at this point in the history
bindata and yaml, Gobindata automation
bindata utils for generating, go generate
match server version
gitignore for dirty, ca, rbase, KUBE_ROOT, buildfix
(rebased jul-25,29)
  • Loading branch information
jayunit100 committed Jul 29, 2016
1 parent 9fab05f commit 6166083
Show file tree
Hide file tree
Showing 13 changed files with 2,114 additions and 5,512 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ kubernetes.tar.gz

# make-related metadata
/.make/
# Just in time generated data in the source, should never be commited
/test/e2e/generated/bindata.go
14 changes: 14 additions & 0 deletions hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ kube::golang::server_targets() {
fi
echo "${targets[@]}"
}

readonly KUBE_SERVER_TARGETS=($(kube::golang::server_targets))
readonly KUBE_SERVER_BINARIES=("${KUBE_SERVER_TARGETS[@]##*/}")

Expand Down Expand Up @@ -454,6 +455,7 @@ kube::golang::build_binaries_for_platform() {
local -a statics=()
local -a nonstatics=()
local -a tests=()

for binary in "${binaries[@]}"; do

# TODO(IBM): Enable hyperkube builds for ppc64le again
Expand Down Expand Up @@ -610,6 +612,18 @@ kube::golang::build_binaries() {
local use_go_build
local -a targets=()
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
if [[ "${arg}" == "--use_go_build" ]]; then
use_go_build=true
Expand Down
1,975 changes: 1,975 additions & 0 deletions hack/test-cmd.sh

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions hack/update-bindata.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
framework.DumpAllNamespaceInfo(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)
}

Expand Down
21 changes: 6 additions & 15 deletions test/e2e/framework/gobindata_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,17 @@ limitations under the License.

package framework

//go:generate ../../../hack/update-bindata.sh

// See https://github.com/kubernetes/kubernetes/issues/23987
import "k8s.io/kubernetes/test/e2e/generated"

/*
ReadOrDie reads a file from gobindata. To generate gobindata, run
# 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
ReadOrDie reads a file from gobindata.
Relies heavily on the successful generation of build artifacts as per the go:generate directives above.
*/
func ReadOrDie(filePath string) []byte {

fileBytes, err := generated.Asset(filePath)
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."
Expand Down
19 changes: 10 additions & 9 deletions test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ type TestContextType struct {
KubeVolumeDir string
CertDir string
Host string
RepoRoot string
Provider string
CloudConfig CloudConfig
KubectlPath string
OutputDir string
ReportDir string
ReportPrefix string
Prefix string
MinStartupPods int
// TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
RepoRoot string
Provider string
CloudConfig CloudConfig
KubectlPath string
OutputDir string
ReportDir string
ReportPrefix string
Prefix string
MinStartupPods int
// Timeout for waiting for system pods to be running
SystemPodsStartupTimeout time.Duration
UpgradeTarget string
Expand Down
15 changes: 8 additions & 7 deletions test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
"math/rand"
"net"
Expand Down Expand Up @@ -640,10 +639,7 @@ func WaitForPodsRunningReady(c *client.Client, ns string, minPods int32, timeout
func podFromManifest(filename string) (*api.Pod, error) {
var pod api.Pod
Logf("Parsing pod from %v", filename)
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
data := ReadOrDie(filename)
json, err := utilyaml.ToJSON(data)
if err != nil {
return nil, err
Expand All @@ -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
// to flip to Ready, log its output and delete it.
func RunKubernetesServiceTestContainer(c *client.Client, repoRoot string, ns string) {
path := filepath.Join(repoRoot, "test", "images", "clusterapi-tester", "pod.yaml")
func RunKubernetesServiceTestContainer(c *client.Client, ns string) {
c, err := LoadClient()
if err != nil {
Logf("Failed to load client")
return
}
path := "test/images/clusterapi-tester/pod.yaml"
p, err := podFromManifest(path)
if err != nil {
Logf("Failed to parse clusterapi-tester from manifest %v: %v", path, err)
Expand Down
Loading

0 comments on commit 6166083

Please sign in to comment.