Skip to content

Commit

Permalink
Merge pull request kubernetes#10606 from nikhiljindal/testsToV1
Browse files Browse the repository at this point in the history
Update tests/examples to v1
  • Loading branch information
zmerlynn committed Jul 1, 2015
2 parents e3e024d + 274792d commit b27a8e1
Show file tree
Hide file tree
Showing 37 changed files with 117 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cluster/addons/fluentd-elasticsearch/es-service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-logging
Expand Down
3 changes: 1 addition & 2 deletions cluster/addons/fluentd-elasticsearch/kibana-service.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

apiVersion: v1beta3
apiVersion: v1
kind: Service
metadata:
name: kibana-logging
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cluster/images/hyperkube/master-multi.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"k8s-master"},
"spec":{
Expand Down
2 changes: 1 addition & 1 deletion cluster/images/hyperkube/master.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"k8s-master"},
"spec":{
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/etcd/etcd.manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"etcd-server"},
"spec":{
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/fluentd-es/fluentd-es.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
name: fluentd-elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/fluentd-gcp/fluentd-gcp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1beta3
apiVersion: v1
kind: Pod
metadata:
name: fluentd-cloud-logging
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/kube-addons/kube-addon-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/kube-addons/kube-addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: "v1beta3"
apiVersion: "v1"
kind: "LimitRange"
metadata:
name: "limits"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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":{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"kube-scheduler"},
"spec":{
Expand Down
2 changes: 1 addition & 1 deletion cluster/saltbase/salt/nginx/nginx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"apiVersion": "v1beta3",
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name":"nginx"},
"spec":{
Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions hack/e2e-suite/services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function make_namespace() {
${KUBECTL} create -f - << __EOF__
{
"kind": "Namespace",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "${TEST_NAMESPACE}"
}
Expand All @@ -90,7 +90,7 @@ function start_service() {
${KUBECTL} create -f - << __EOF__
{
"kind": "ReplicationController",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "$1",
"labels": {
Expand Down Expand Up @@ -135,7 +135,7 @@ __EOF__
${KUBECTL} create -f - << __EOF__
{
"kind": "Service",
"apiVersion": "v1beta3",
"apiVersion": "v1",
"metadata": {
"name": "$1",
"labels": {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
Expand Down
1 change: 0 additions & 1 deletion hack/local-up-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
27 changes: 17 additions & 10 deletions hack/test-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand All @@ -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=$!
Expand All @@ -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}"
Expand Down Expand Up @@ -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"}]}}'
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
4 changes: 2 additions & 2 deletions hack/test-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions hack/update-swagger-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=$!

Expand Down
3 changes: 2 additions & 1 deletion pkg/api/latest/latest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}

Expand Down
Loading

0 comments on commit b27a8e1

Please sign in to comment.