mirror of https://github.com/k3s-io/k3s
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
commit
df0d5826f5
|
@ -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
|
||||
|
|
|
@ -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[@]##*/}")
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
1975
hack/test-cmd.sh
1975
hack/test-cmd.sh
File diff suppressed because it is too large
Load Diff
|
@ -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"
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -33,6 +33,7 @@ type TestContextType struct {
|
|||
KubeVolumeDir string
|
||||
CertDir string
|
||||
Host string
|
||||
// TODO: Deprecating this over time... instead just use gobindata_util.go , see #23987.
|
||||
RepoRoot string
|
||||
Provider string
|
||||
CloudConfig CloudConfig
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net"
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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.
|
|
@ -18,7 +18,6 @@ package e2e
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"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.")
|
||||
labelPodName := "with-labels"
|
||||
nodeSelectionRoot := filepath.Join(framework.TestContext.RepoRoot, "test/e2e/testing-manifests/node-selection")
|
||||
testPodPath := filepath.Join(nodeSelectionRoot, "pod-with-node-affinity.yaml")
|
||||
testPodPath := string(framework.ReadOrDie("test/e2e/testing-manifests/node-selection/pod-with-node-affinity.yaml"))
|
||||
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
|
||||
|
||||
// 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.")
|
||||
labelPodName := "with-newlabels"
|
||||
nodeSelectionRoot := filepath.Join(framework.TestContext.RepoRoot, "test/e2e/testing-manifests/node-selection")
|
||||
testPodPath := filepath.Join(nodeSelectionRoot, "pod-with-pod-affinity.yaml")
|
||||
testPodPath := string(framework.ReadOrDie("test/e2e/testing-manifests/node-selection/pos-with-node-affinity.yaml"))
|
||||
framework.RunKubectlOrDie("create", "-f", testPodPath, fmt.Sprintf("--namespace=%v", ns))
|
||||
|
||||
// check that pod got scheduled. We intentionally DO NOT check that the
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
|
@ -35,23 +34,23 @@ import (
|
|||
)
|
||||
|
||||
// getLoadBalancerControllers returns a list of LBCtesters.
|
||||
func getLoadBalancerControllers(repoRoot string, client *client.Client) []LBCTester {
|
||||
func getLoadBalancerControllers(client *client.Client) []LBCTester {
|
||||
return []LBCTester{
|
||||
&haproxyControllerTester{
|
||||
name: "haproxy",
|
||||
cfg: filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "haproxyrc.yaml"),
|
||||
cfg: "test/e2e/testing-manifests/serviceloadbalancer/haproxyrc.yaml",
|
||||
client: client,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// getIngManagers returns a list of ingManagers.
|
||||
func getIngManagers(repoRoot string, client *client.Client) []*ingManager {
|
||||
func getIngManagers(client *client.Client) []*ingManager {
|
||||
return []*ingManager{
|
||||
{
|
||||
name: "netexec",
|
||||
rcCfgPaths: []string{filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "netexecrc.yaml")},
|
||||
svcCfgPaths: []string{filepath.Join(repoRoot, "test", "e2e", "testing-manifests", "serviceloadbalancer", "netexecsvc.yaml")},
|
||||
rcCfgPaths: []string{"test/e2e/testing-manifests/serviceloadbalancer/netexecrc.yaml"},
|
||||
svcCfgPaths: []string{"test/e2e/testing-manifests/serviceloadbalancer/netexecsvc.yaml"},
|
||||
svcNames: []string{},
|
||||
client: client,
|
||||
},
|
||||
|
@ -208,7 +207,6 @@ func (s *ingManager) test(path string) error {
|
|||
var _ = framework.KubeDescribe("ServiceLoadBalancer [Feature:ServiceLoadBalancer]", func() {
|
||||
// These variables are initialized after framework's beforeEach.
|
||||
var ns string
|
||||
var repoRoot string
|
||||
var client *client.Client
|
||||
|
||||
f := framework.NewDefaultFramework("servicelb")
|
||||
|
@ -216,15 +214,14 @@ var _ = framework.KubeDescribe("ServiceLoadBalancer [Feature:ServiceLoadBalancer
|
|||
BeforeEach(func() {
|
||||
client = f.Client
|
||||
ns = f.Namespace.Name
|
||||
repoRoot = framework.TestContext.RepoRoot
|
||||
})
|
||||
|
||||
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))
|
||||
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))
|
||||
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 {
|
||||
var controller api.ReplicationController
|
||||
framework.Logf("Parsing rc from %v", fileName)
|
||||
data, err := ioutil.ReadFile(fileName)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
data := framework.ReadOrDie(fileName)
|
||||
|
||||
json, err := utilyaml.ToJSON(data)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -282,8 +278,7 @@ func rcFromManifest(fileName string) *api.ReplicationController {
|
|||
func svcFromManifest(fileName string) *api.Service {
|
||||
var svc api.Service
|
||||
framework.Logf("Parsing service from %v", fileName)
|
||||
data, err := ioutil.ReadFile(fileName)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
data := framework.ReadOrDie(fileName)
|
||||
|
||||
json, err := utilyaml.ToJSON(data)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
|
|
@ -28,7 +28,16 @@ set -x
|
|||
|
||||
. $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
|
||||
|
||||
# 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
|
||||
|
||||
WORKSPACE=${WORKSPACE:-"/tmp/"}
|
||||
|
|
Loading…
Reference in New Issue