Merge pull request #10606 from nikhiljindal/testsToV1

Update tests/examples to v1
pull/6/head
Zach Loafman 2015-07-01 15:53:54 -07:00
commit b27a8e1d90
37 changed files with 117 additions and 242 deletions

View File

@ -34,7 +34,7 @@ spec:
name: grafana
env:
- name: INFLUXDB_EXTERNAL_URL
value: /api/v1beta3/proxy/namespaces/default/services/monitoring-influxdb:api/db/
value: /api/v1/proxy/namespaces/default/services/monitoring-influxdb:api/db/
- name: INFLUXDB_HOST
value: monitoring-influxdb
- name: INFLUXDB_PORT

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-logging

View File

@ -1,5 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
name: kibana-logging

View File

@ -728,7 +728,7 @@ function kube-up {
-H "Authorization: Bearer ${KUBE_BEARER_TOKEN}" \
${secure} \
--max-time 5 --fail --output /dev/null --silent \
"https://${KUBE_MASTER_IP}/api/v1beta3/pods"; do
"https://${KUBE_MASTER_IP}/api/v1/pods"; do
printf "."
sleep 2
done

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"k8s-master"},
"spec":{

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"k8s-master"},
"spec":{

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"etcd-server"},
"spec":{

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
name: fluentd-elasticsearch

View File

@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
name: fluentd-cloud-logging

View File

@ -192,7 +192,7 @@ function run-until-success() {
# returns a list of <namespace>/<name> pairs (nsnames)
function get-addon-nsnames-from-server() {
local -r obj_type=$1
"${KUBECTL}" get "${obj_type}" --all-namespaces -o template -t "{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" --api-version=v1beta3 -l kubernetes.io/cluster-service=true
"${KUBECTL}" get "${obj_type}" --all-namespaces -o template -t "{{range.items}}{{.metadata.namespace}}/{{.metadata.name}} {{end}}" --api-version=v1 -l kubernetes.io/cluster-service=true
}
# returns the characters after the last separator (including)

View File

@ -74,7 +74,7 @@ EOF
local -r kubeconfig_base64=$(echo "${kubeconfig}" | base64 -w0)
read -r -d '' secretyaml <<EOF
apiVersion: v1beta3
apiVersion: v1
data:
kubeconfig: ${kubeconfig_base64}
kind: Secret

View File

@ -1,4 +1,4 @@
apiVersion: "v1beta3"
apiVersion: "v1"
kind: "LimitRange"
metadata:
name: "limits"

View File

@ -89,7 +89,7 @@
{% set params = params + " " + cluster_name + " " + cert_file + " " + key_file + " --secure_port=" + secure_port + " " + token_auth_file + " " + bind_address + " " + pillar['log_level'] + " " + advertise_address + " " + proxy_ssh_options -%}
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-apiserver"},
"spec":{

View File

@ -37,7 +37,7 @@
{% set params = "--master=127.0.0.1:8080" + " " + cluster_name + " " + cluster_cidr + " " + allocate_node_cidrs + " " + cloud_provider + " " + cloud_config + service_account_key + pillar['log_level'] + " " + root_ca_file -%}
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-controller-manager"},
"spec":{

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-scheduler"},
"spec":{

View File

@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"nginx"},
"spec":{

View File

@ -436,7 +436,7 @@ func TestExecutorStaticPods(t *testing.T) {
w, err := zw.Create(fileName)
assert.NoError(t, err)
spod := `{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "%v",

View File

@ -71,7 +71,7 @@ function make_namespace() {
${KUBECTL} create -f - << __EOF__
{
"kind": "Namespace",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "${TEST_NAMESPACE}"
}
@ -90,7 +90,7 @@ function start_service() {
${KUBECTL} create -f - << __EOF__
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "$1",
"labels": {
@ -135,7 +135,7 @@ __EOF__
${KUBECTL} create -f - << __EOF__
{
"kind": "Service",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "$1",
"labels": {
@ -177,7 +177,7 @@ function query_pods() {
for i in $(seq 1 10); do
pods_unsorted=($(${KUBECTL} get pods -o template \
'--template={{range.items}}{{.metadata.name}} {{end}}' \
'--api-version=v1beta3' \
'--api-version=v1' \
-l name="$1"))
found="${#pods_unsorted[*]}"
if [[ "${found}" == "$2" ]]; then
@ -211,7 +211,7 @@ function wait_for_pods() {
echo "Waiting for ${pods_needed} pods to become 'running'"
pods_needed="$2"
for id in ${pods_sorted}; do
status=$(${KUBECTL} get pods "${id}" -o template --template='{{.status.phase}}' --api-version=v1beta3)
status=$(${KUBECTL} get pods "${id}" -o template --template='{{.status.phase}}' --api-version=v1)
if [[ "${status}" == "Running" ]]; then
pods_needed=$((pods_needed-1))
fi
@ -337,9 +337,9 @@ svc1_pods=$(query_pods "${svc1_name}" "${svc1_count}")
svc2_pods=$(query_pods "${svc2_name}" "${svc2_count}")
# Get the VIP IPs.
svc1_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc1_name}" --api-version=v1beta3)
svc1_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc1_name}" --api-version=v1)
test -n "${svc1_ip}" || error "Service1 IP is blank"
svc2_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc2_name}" --api-version=v1beta3)
svc2_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc2_name}" --api-version=v1)
test -n "${svc2_ip}" || error "Service2 IP is blank"
if [[ "${svc1_ip}" == "${svc2_ip}" ]]; then
error "VIPs conflict: ${svc1_ip}"
@ -409,7 +409,7 @@ wait_for_pods "${svc3_name}" "${svc3_count}"
svc3_pods=$(query_pods "${svc3_name}" "${svc3_count}")
# Get the VIP.
svc3_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc3_name}" --api-version=v1beta3)
svc3_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc3_name}" --api-version=v1)
test -n "${svc3_ip}" || error "Service3 IP is blank"
echo "Verifying the VIPs from the host"
@ -464,7 +464,7 @@ wait_for_pods "${svc4_name}" "${svc4_count}"
svc4_pods=$(query_pods "${svc4_name}" "${svc4_count}")
# Get the VIP.
svc4_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc4_name}" --api-version=v1beta3)
svc4_ip=$(${KUBECTL} get services -o template '--template={{.spec.portalIP}}' "${svc4_name}" --api-version=v1)
test -n "${svc4_ip}" || error "Service4 IP is blank"
if [[ "${svc4_ip}" == "${svc2_ip}" || "${svc4_ip}" == "${svc3_ip}" ]]; then
error "VIPs conflict: ${svc4_ip}"

View File

@ -213,7 +213,6 @@ function start_apiserver {
--admission_control="${ADMISSION_CONTROL}" \
--address="${API_HOST}" \
--port="${API_PORT}" \
--runtime_config=api/v1beta3 \
--etcd_servers="http://127.0.0.1:4001" \
--service-cluster-ip-range="10.0.0.0/24" \
--cors_allowed_origins="${API_CORS_ALLOWED_ORIGINS}" >"${APISERVER_LOG}" 2>&1 &

View File

@ -125,7 +125,7 @@ kube::util::wait_for_url "http://127.0.0.1:${KUBELET_HEALTHZ_PORT}/healthz" "kub
# Start kube-apiserver
kube::log::status "Starting kube-apiserver"
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
--address="127.0.0.1" \
--public_address_override="127.0.0.1" \
--port="${API_PORT}" \
@ -134,6 +134,7 @@ kube::log::status "Starting kube-apiserver"
--kubelet_port=${KUBELET_PORT} \
--runtime_config=api/v1beta3 \
--runtime_config=api/v1 \
--runtime_config=api/v1beta3 \
--cert_dir="${TMPDIR:-/tmp/}" \
--service-cluster-ip-range="10.0.0.0/24" 1>&2 &
APISERVER_PID=$!
@ -148,17 +149,14 @@ kube::log::status "Starting controller-manager"
CTLRMGR_PID=$!
kube::util::wait_for_url "http://127.0.0.1:${CTLRMGR_PORT}/healthz" "controller-manager"
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1beta3/nodes/127.0.0.1" "apiserver(nodes)"
kube::util::wait_for_url "http://127.0.0.1:${API_PORT}/api/v1/nodes/127.0.0.1" "apiserver(nodes)"
# Expose kubectl directly for readability
PATH="${KUBE_OUTPUT_HOSTBIN}":$PATH
kube_api_versions=(
""
v1beta3
v1
)
for version in "${kube_api_versions[@]}"; do
runTests() {
version="$1"
echo "Testing api version: $1"
if [[ -z "${version}" ]]; then
kube_flags=(
-s "http://127.0.0.1:${API_PORT}"
@ -377,7 +375,7 @@ for version in "${kube_api_versions[@]}"; do
kubectl create -f examples/limitrange/valid-pod.json "${kube_flags[@]}"
# Post-condition: valid-pod POD is running
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" 'valid-pod:'
## Patch pod can change image
# Command
kubectl patch "${kube_flags[@]}" pod valid-pod -p='{"spec":{"containers":[{"name": "kubernetes-serve-hostname", "image": "nginx"}]}}'
@ -523,7 +521,7 @@ for version in "${kube_api_versions[@]}"; do
kubectl create -f - "${kube_flags[@]}" << __EOF__
{
"kind": "Service",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "service-${version}-test"
},
@ -784,6 +782,15 @@ __EOF__
fi
kube::test::clear_all
}
kube_api_versions=(
""
v1beta3
v1
)
for version in "${kube_api_versions[@]}"; do
KUBE_API_VERSIONS="v1,v1beta3" runTests "${version}"
done
kube::log::status "TEST PASSED"

View File

@ -53,7 +53,7 @@ KUBE_RACE=${KUBE_RACE:-} # use KUBE_RACE="-race" to enable race testing
# Set to the goveralls binary path to report coverage results to Coveralls.io.
KUBE_GOVERALLS_BIN=${KUBE_GOVERALLS_BIN:-}
# Comma separated list of API Versions that should be tested.
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1beta3,v1"}
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,v1beta3"}
# Run tests with the standard (registry) and a custom etcd prefix
# (kubernetes.io/registry).
KUBE_TEST_ETCD_PREFIXES=${KUBE_TEST_ETCD_PREFIXES:-"registry,kubernetes.io/registry"}
@ -218,7 +218,7 @@ for (( i=0, j=0; ; )); do
apiVersion=${apiVersions[i]}
etcdPrefix=${etcdPrefixes[j]}
echo "Running tests for APIVersion: $apiVersion with etcdPrefix: $etcdPrefix"
KUBE_API_VERSION="${apiVersion}" ETCD_PREFIX=${etcdPrefix} runTests "$@"
KUBE_API_VERSION="${apiVersion}" KUBE_API_VERSIONS="v1,v1beta3" ETCD_PREFIX=${etcdPrefix} runTests "$@"
i=${i}+1
j=${j}+1
if [[ i -eq ${apiVersionsCount} ]] && [[ j -eq ${etcdPrefixesCount} ]]; then

View File

@ -25,7 +25,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
# Comma separated list of API Versions that should be tested.
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1beta3,v1"}
KUBE_TEST_API_VERSIONS=${KUBE_TEST_API_VERSIONS:-"v1,v1beta3"}
KUBE_INTEGRATION_TEST_MAX_CONCURRENCY=${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY:-"-1"}
LOG_LEVEL=${LOG_LEVEL:-2}
@ -39,20 +39,22 @@ runTests() {
kube::etcd::start
kube::log::status "Running integration test cases"
KUBE_GOFLAGS="-tags 'integration no-docker' " \
KUBE_RACE="-race" \
KUBE_TEST_API_VERSIONS="$1" \
KUBE_API_VERSIONS="v1,v1beta3" \
"${KUBE_ROOT}/hack/test-go.sh" test/integration
kube::log::status "Running integration test scenario"
"${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" \
--max-concurrency="${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY}"
cleanup
}
"${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration
# Run cleanup to stop etcd on interrupt or other kill signal.
trap cleanup EXIT

View File

@ -46,14 +46,14 @@ KUBELET_PORT=${KUBELET_PORT:-10250}
# Start kube-apiserver
kube::log::status "Starting kube-apiserver"
"${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
KUBE_API_VERSIONS="v1,v1beta3" "${KUBE_OUTPUT_HOSTBIN}/kube-apiserver" \
--address="127.0.0.1" \
--public_address_override="127.0.0.1" \
--port="${API_PORT}" \
--etcd_servers="http://${ETCD_HOST}:${ETCD_PORT}" \
--public_address_override="127.0.0.1" \
--kubelet_port=${KUBELET_PORT} \
--runtime_config=api/legacy=false \
--runtime_config=api/v1beta3 \
--service-cluster-ip-range="10.0.0.0/24" 1>&2 &
APISERVER_PID=$!

View File

@ -34,7 +34,7 @@ var Version string
// OldestVersion is the string that represents the oldest server version supported,
// for client code that wants to hardcode the lowest common denominator.
const OldestVersion = "v1beta3"
var OldestVersion string
// Versions is the list of versions that are recognized in code. The order provided
// may be assumed to be least feature rich to most feature rich, and clients may
@ -67,6 +67,7 @@ var userResources = []string{"rc", "svc", "pods", "pvc"}
func init() {
// Use the first API version in the list of registered versions as the latest.
Version = registered.RegisteredVersions[0]
OldestVersion = registered.RegisteredVersions[len(registered.RegisteredVersions)-1]
Codec = runtime.CodecFor(api.Scheme, Version)
// Put the registered versions in Versions in reverse order.
versions := registered.RegisteredVersions

View File

@ -26,9 +26,8 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
apitesting "github.com/GoogleCloudPlatform/kubernetes/pkg/api/testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/davecgh/go-spew/spew"
@ -88,13 +87,10 @@ func roundTripSame(t *testing.T, item runtime.Object, except ...string) {
set := util.NewStringSet(except...)
seed := rand.Int63()
fuzzInternalObject(t, "", item, seed)
if !set.Has("v1beta3") {
fuzzInternalObject(t, "v1beta3", item, seed)
roundTrip(t, v1beta3.Codec, item)
}
if !set.Has("v1") {
fuzzInternalObject(t, "v1", item, seed)
roundTrip(t, v1.Codec, item)
version := testapi.Version()
if !set.Has(version) {
fuzzInternalObject(t, version, item, seed)
roundTrip(t, testapi.Codec(), item)
}
}

View File

@ -84,7 +84,7 @@ func TestBadSecurityContextConversion(t *testing.T) {
c *versioned.Container
err string
}{
// this use case must use true for the container and false for the sc. Otherwise the defaulter
// this use case must use true for the container and false for the sc. Otherwise the defaulter
// will assume privileged was left undefined (since it is the default value) and copy the
// sc setting upwards
"mismatched privileged": {

View File

@ -24,6 +24,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
utilerrors "github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
@ -556,7 +557,7 @@ func TestValidateEnv(t *testing.T) {
Name: "abc",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
FieldPath: "metadata.name",
},
},
@ -588,7 +589,7 @@ func TestValidateEnv(t *testing.T) {
Value: "foo",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
FieldPath: "metadata.name",
},
},
@ -601,7 +602,7 @@ func TestValidateEnv(t *testing.T) {
Name: "abc",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
},
},
}},
@ -626,7 +627,7 @@ func TestValidateEnv(t *testing.T) {
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
FieldPath: "metadata.whoops",
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
},
},
}},
@ -639,7 +640,7 @@ func TestValidateEnv(t *testing.T) {
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
FieldPath: "status.phase",
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
},
},
}},

View File

@ -31,7 +31,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
@ -174,7 +173,7 @@ func MatchesServerVersion(client *Client, c *Config) error {
// stderr and try client's registered versions in order of preference.
// - If version is config default, and the server does not support it,
// return an error.
func NegotiateVersion(client *Client, c *Config, version string) (string, error) {
func NegotiateVersion(client *Client, c *Config, version string, clientRegisteredVersions []string) (string, error) {
var err error
if client == nil {
client, err = New(c)
@ -183,7 +182,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error)
}
}
clientVersions := util.StringSet{}
for _, v := range registered.RegisteredVersions {
for _, v := range clientRegisteredVersions {
clientVersions.Insert(v)
}
apiVersions, err := client.ServerAPIVersions()
@ -214,7 +213,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error)
}
}
for _, clientVersion := range registered.RegisteredVersions {
for _, clientVersion := range clientRegisteredVersions {
if serverVersions.Has(clientVersion) {
// Version was not explicitly requested in command config (--api-version).
// Ok to fall back to a supported version with a warning.
@ -225,7 +224,7 @@ func NegotiateVersion(client *Client, c *Config, version string) (string, error)
}
}
return "", fmt.Errorf("Failed to negotiate an api version. Server supports: %v. Client supports: %v.",
serverVersions, registered.RegisteredVersions)
serverVersions, clientRegisteredVersions)
}
// NewOrDie creates a Kubernetes client and panics if the provided API version is not recognized.

View File

@ -333,39 +333,44 @@ func TestNegotiateVersion(t *testing.T) {
tests := []struct {
name, version, expectedVersion string
serverVersions []string
clientVersions []string
config *Config
expectErr bool
}{
{
name: "server supports client default",
version: "v1",
expectedVersion: "v1",
version: "version1",
config: &Config{},
serverVersions: []string{"v1beta3", "v1"},
serverVersions: []string{"version1", testapi.Version()},
clientVersions: []string{"version1", testapi.Version()},
expectedVersion: "version1",
expectErr: false,
},
{
name: "server falls back to client supported",
version: "v1",
expectedVersion: "v1beta3",
version: testapi.Version(),
config: &Config{},
serverVersions: []string{"v1beta3"},
serverVersions: []string{"version1"},
clientVersions: []string{"version1", testapi.Version()},
expectedVersion: "version1",
expectErr: false,
},
{
name: "explicit version supported",
version: "",
expectedVersion: "v1",
config: &Config{Version: "v1"},
serverVersions: []string{"v1beta3", "v1"},
config: &Config{Version: testapi.Version()},
serverVersions: []string{"version1", testapi.Version()},
clientVersions: []string{"version1", testapi.Version()},
expectedVersion: testapi.Version(),
expectErr: false,
},
{
name: "explicit version not supported",
version: "",
config: &Config{Version: testapi.Version()},
serverVersions: []string{"version1"},
clientVersions: []string{"version1", testapi.Version()},
expectedVersion: "",
config: &Config{Version: "v1"},
serverVersions: []string{"v1beta3"},
expectErr: true,
},
}
@ -384,7 +389,7 @@ func TestNegotiateVersion(t *testing.T) {
}
c := NewOrDie(test.config)
c.Client = fakeClient.Client
response, err := NegotiateVersion(c, test.config, test.version)
response, err := NegotiateVersion(c, test.config, test.version, test.clientVersions)
if err == nil && test.expectErr {
t.Errorf("expected error, got nil for [%s].", test.name)
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/registered"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd"
)
@ -59,7 +60,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er
}
// TODO: have a better config copy method
config := *c.defaultConfig
negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version)
negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version, registered.RegisteredVersions)
if err != nil {
return nil, err
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
@ -26,6 +27,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors"
)
@ -45,7 +47,7 @@ func TestMerge(t *testing.T) {
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1beta3" }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s" }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@ -77,7 +79,7 @@ func TestMerge(t *testing.T) {
},
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@ -103,7 +105,7 @@ func TestMerge(t *testing.T) {
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`, testapi.Version()),
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
@ -142,7 +144,7 @@ func TestMerge(t *testing.T) {
obj: &api.Service{
Spec: api.ServiceSpec{},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "ports": [ { "port": 0 } ] } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "ports": [ { "port": 0 } ] } }`, testapi.Version()),
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
@ -165,145 +167,7 @@ func TestMerge(t *testing.T) {
},
},
},
fragment: `{ "apiVersion": "v1beta3", "spec": { "selector": { "version": "v2" } } }`,
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
Type: api.ServiceTypeClusterIP,
Selector: map[string]string{
"version": "v2",
},
},
},
},
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1" }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
/* TODO: uncomment this test once Merge is updated to use
strategic-merge-patch. See #8449.
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Containers: []api.Container{
api.Container{
Name: "c1",
Image: "red-image",
},
api.Container{
Name: "c2",
Image: "blue-image",
},
},
},
},
fragment: `{ "apiVersion": "v1", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Containers: []api.Container{
api.Container{
Name: "c1",
Image: "green-image",
},
api.Container{
Name: "c2",
Image: "blue-image",
},
},
},
},
}, */
{
kind: "Pod",
obj: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
},
fragment: `{ "apiVersion": "v1", "spec": { "volumes": [ {"name": "v1"}, {"name": "v2"} ] } }`,
expected: &api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
},
Spec: api.PodSpec{
Volumes: []api.Volume{
{
Name: "v1",
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}},
},
{
Name: "v2",
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}},
},
},
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
},
},
},
{
kind: "Pod",
obj: &api.Pod{},
fragment: "invalid json",
expected: &api.Pod{},
expectErr: true,
},
{
kind: "Service",
obj: &api.Service{},
fragment: `{ "apiVersion": "badVersion" }`,
expectErr: true,
},
{
kind: "Service",
obj: &api.Service{
Spec: api.ServiceSpec{},
},
fragment: `{ "apiVersion": "v1", "spec": { "ports": [ { "port": 0 } ] } }`,
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",
Type: api.ServiceTypeClusterIP,
Ports: []api.ServicePort{
{
Protocol: api.ProtocolTCP,
Port: 0,
},
},
},
},
},
{
kind: "Service",
obj: &api.Service{
Spec: api.ServiceSpec{
Selector: map[string]string{
"version": "v1",
},
},
},
fragment: `{ "apiVersion": "v1", "spec": { "selector": { "version": "v2" } } }`,
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "selector": { "version": "v2" } } }`, testapi.Version()),
expected: &api.Service{
Spec: api.ServiceSpec{
SessionAffinity: "None",

View File

@ -34,6 +34,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
apierrors "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/testclient"
@ -1172,7 +1173,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Name: "POD_NAME",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
FieldPath: "metadata.name",
},
},
@ -1181,7 +1182,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Name: "POD_NAMESPACE",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
FieldPath: "metadata.namespace",
},
},
@ -1208,7 +1209,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Name: "POD_NAME",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
FieldPath: "metadata.name",
},
},

View File

@ -26,6 +26,7 @@ import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
@ -131,19 +132,16 @@ func compareBuffers(t *testing.T, generatedFile string, existing, generated byte
}
func TestNoManualChangesToGenerateConversions(t *testing.T) {
versions := []string{"v1beta3", "v1"}
version := testapi.Version()
fileName := fmt.Sprintf("../../pkg/api/%s/conversion_generated.go", version)
for _, version := range versions {
fileName := fmt.Sprintf("../../pkg/api/%s/conversion_generated.go", version)
existingFunctions := bufferExistingGeneratedCode(t, fileName)
generatedFunctions := generateConversions(t, version)
existingFunctions := bufferExistingGeneratedCode(t, fileName)
generatedFunctions := generateConversions(t, version)
functionsTxt := fmt.Sprintf("%s.functions.txt", version)
ioutil.WriteFile(functionsTxt, generatedFunctions.Bytes(), os.FileMode(0644))
functionsTxt := fmt.Sprintf("%s.functions.txt", version)
ioutil.WriteFile(functionsTxt, generatedFunctions.Bytes(), os.FileMode(0644))
if ok := compareBuffers(t, functionsTxt, existingFunctions, generatedFunctions); ok {
os.Remove(functionsTxt)
}
if ok := compareBuffers(t, functionsTxt, existingFunctions, generatedFunctions); ok {
os.Remove(functionsTxt)
}
}

View File

@ -25,6 +25,7 @@ import (
"testing"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta3"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
@ -64,7 +65,7 @@ func generateDeepCopies(t *testing.T, version string) bytes.Buffer {
}
func TestNoManualChangesToGenerateDeepCopies(t *testing.T) {
versions := []string{"api", "v1beta3", "v1"}
versions := []string{"api", testapi.Version()}
for _, version := range versions {
fileName := ""

View File

@ -21,6 +21,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -162,7 +163,7 @@ func makeCheckPod(ns string, nfsserver string) *api.Pod {
return &api.Pod{
TypeMeta: api.TypeMeta{
Kind: "Pod",
APIVersion: "v1beta3",
APIVersion: testapi.Version(),
},
ObjectMeta: api.ObjectMeta{
GenerateName: "checker-",

View File

@ -24,6 +24,7 @@ import (
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
@ -34,9 +35,8 @@ import (
)
var _ = Describe("Proxy", func() {
for _, version := range []string{"v1beta3", "v1"} {
Context("version "+version, func() { proxyContext(version) })
}
version := testapi.Version()
Context("version "+version, func() { proxyContext(version) })
})
const (

View File

@ -56,7 +56,7 @@ http-server -a localhost -p 8001
Note that you'll need to tell the application where to find the api server by setting the value of the `k8sApiServer` configuration parameter in `www/master/shared/config/development.json` and then rebuilding the application. For example, for a cluster running locally at `localhost:8080`, as described [here](../docs/getting-started-guides/locally.md), you'll want to set it as follows:
```
"k8sApiServer": "http://localhost:8080/api/v1beta3"
"k8sApiServer": "http://localhost:8080/api/v1"
```
### Building the app for production