Skip to content

Commit

Permalink
Convert kubeadm pull job to scenario.
Browse files Browse the repository at this point in the history
This also changes the --kubeadm boolean flag in kubernetes_e2e.py to an
option to specify the type of job (ci, pull, periodic) so that it knows
where to find the .deb artifacts created by the previous bazel job,
since the output location can differ by type.
  • Loading branch information
pipejakob committed May 9, 2017
1 parent b373ed7 commit 1b011d1
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 106 deletions.
18 changes: 14 additions & 4 deletions jobs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,7 @@
"--cluster=",
"--env-file=platforms/gce.env",
"--env-file=jobs/ci-kubernetes-e2e-kubeadm-gce.env",
"--kubeadm",
"--kubeadm=ci",
"--mode=local"
],
"scenario": "kubernetes_e2e"
Expand All @@ -2118,7 +2118,7 @@
"--cluster=",
"--env-file=platforms/gce.env",
"--env-file=jobs/ci-kubernetes-e2e-kubeadm-gce-1-6.env",
"--kubeadm",
"--kubeadm=ci",
"--mode=local"
],
"scenario": "kubernetes_e2e"
Expand Down Expand Up @@ -2667,7 +2667,7 @@
"--cluster=",
"--env-file=platforms/gce.env",
"--env-file=jobs/periodic-kubernetes-e2e-kubeadm-gce-1-6.env",
"--kubeadm",
"--kubeadm=periodic",
"--mode=local"
],
"scenario": "kubernetes_e2e"
Expand Down Expand Up @@ -2764,6 +2764,16 @@
],
"scenario": "kubernetes_e2e"
},
"pull-kubernetes-e2e-kubeadm-gce": {
"args": [
"--cluster=",
"--env-file=platforms/gce.env",
"--env-file=jobs/pull-kubernetes-e2e-kubeadm-gce.env",
"--kubeadm=pull",
"--mode=local"
],
"scenario": "kubernetes_e2e"
},
"pull-kubernetes-federation-e2e-gce": {
"args": [
"--env-file=platforms/gce.env",
Expand Down Expand Up @@ -2820,4 +2830,4 @@
],
"scenario": "kubernetes_verify"
}
}
}
15 changes: 15 additions & 0 deletions jobs/pull-kubernetes-e2e-kubeadm-gce.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### job-env

PROJECT=k8s-jkns-pr-kubeadm
KUBERNETES_PROVIDER=kubernetes-anywhere

GINKGO_PARALLEL=y
GINKGO_TEST_ARGS='--ginkgo.focus=\[Conformance\] --ginkgo.skip=\[Slow\]|\[Serial\]|\[Disruptive\]|\[Flaky\]'

# Resource leak detection is disabled because prow runs multiple instances of
# this job in the same project concurrently, and resource leak detection will
# make the job flaky.
FAIL_ON_GCP_RESOURCE_LEAK=false

# After post-env
KUBEKINS_TIMEOUT=120m
73 changes: 0 additions & 73 deletions jobs/pull-kubernetes-e2e-kubeadm-gce.sh

This file was deleted.

60 changes: 36 additions & 24 deletions scenarios/kubernetes_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ def kubekins(tag):
return 'gcr.io/k8s-testimages/kubekins-e2e:%s' % tag


def kubeadm_version(mode):
version = ''
if mode in ['ci', 'periodic']:
# This job only runs against the kubernetes repo, and bootstrap.py leaves the
# current working directory at the repository root. Grab the SCM_REVISION so we
# can use the .debs built during the bazel-build job that should have already
# succeeded.
status = re.search(
r'STABLE_BUILD_SCM_REVISION ([^\n]+)',
check_output('hack/print-workspace-status.sh')
)
if not status:
raise ValueError('STABLE_BUILD_SCM_REVISION not found')
version = status.group(1)

elif mode == 'pull':
version = '%s/%s' % (os.environ['PULL_NUMBER'], os.getenv('PULL_REFS'))

else:
raise ValueError("Unknown kubeadm mode given: %s" % mode)

# The path given here should match jobs/ci-kubernetes-bazel-build.sh
return 'gs://kubernetes-release-dev/bazel/%s/bin/linux/amd64/' % version


class LocalMode(object):
"""Runs e2e tests by calling e2e-runner.sh."""
def __init__(self, workspace):
Expand Down Expand Up @@ -313,29 +338,16 @@ def main(args):
cluster = args.cluster or 'e2e-gce-%s-%s' % (
os.environ['NODE_NAME'], os.getenv('EXECUTOR_NUMBER', 0))

if args.kubeadm:
# Not from Jenkins
cluster = args.cluster or 'e2e-kubeadm-%s' % os.getenv('BUILD_NUMBER', 0)

# This job only runs against the kubernetes repo, and bootstrap.py leaves the
# current working directory at the repository root. Grab the SCM_REVISION so we
# can use the .debs built during the bazel-build job that should have already
# succeeded.
status = re.search(
r'STABLE_BUILD_SCM_REVISION ([^\n]+)',
check_output('hack/print-workspace-status.sh')
)
if not status:
raise ValueError('STABLE_BUILD_SCM_REVISION not found')

opt = '--deployment kubernetes-anywhere' \
' --kubernetes-anywhere-path /workspace/kubernetes-anywhere' \
' --kubernetes-anywhere-phase2-provider kubeadm' \
' --kubernetes-anywhere-cluster %s' \
' --kubernetes-anywhere-kubeadm-version' \
' gs://kubernetes-release-dev/bazel/%s/build/debs/' % (cluster, status.group(1))
# The gs:// path given here should match jobs/ci-kubernetes-bazel-build.sh
mode.add_environment('E2E_OPT=%s' % opt)
if args.kubeadm is not None:
# Not from Jenkins
cluster = args.cluster or 'e2e-kubeadm-%s' % os.getenv('BUILD_NUMBER', 0)
version = kubeadm_version(args.kubeadm)
opt = '--deployment kubernetes-anywhere' \
' --kubernetes-anywhere-path /workspace/kubernetes-anywhere' \
' --kubernetes-anywhere-phase2-provider kubeadm' \
' --kubernetes-anywhere-cluster %s' \
' --kubernetes-anywhere-kubeadm-version %s' % (cluster, version)
mode.add_environment('E2E_OPT=%s' % opt)

# env blacklist.
# TODO(krzyzacy) change this to a whitelist
Expand Down Expand Up @@ -435,7 +447,7 @@ def create_parser():
parser.add_argument(
'--down', default='true', help='If we need to set --down in e2e.go')
parser.add_argument(
'--kubeadm', action='store_true', help='If the test is a kubeadm job')
'--kubeadm', choices=['ci', 'periodic', 'pull'])
parser.add_argument(
'--soak-test', action='store_true', help='If the test is a soak test job')
parser.add_argument(
Expand Down
49 changes: 44 additions & 5 deletions scenarios/kubernetes_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"""Test for kubernetes_e2e.py"""

import json
import os
import re
import shutil
import string
Expand Down Expand Up @@ -111,24 +112,62 @@ def test_local(self):
for call in self.callstack:
self.assertFalse(call.startswith('docker'))

def test_kubeadm(self):
"""Make sure kubeadm mode is fine overall."""
args = self.parser.parse_args(['--mode=local', '--kubeadm'])
def test_kubeadm_ci(self):
"""Make sure kubeadm ci mode is fine overall."""
args = self.parser.parse_args(['--mode=local', '--kubeadm=ci'])
self.assertEqual(args.mode, 'local')
self.assertEqual(args.kubeadm, True)
self.assertEqual(args.kubeadm, 'ci')
with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
with Stub(kubernetes_e2e, 'check_output', self.fake_output_work_status):
kubernetes_e2e.main(args)

self.assertIn('E2E_OPT', self.envs)
self.assertIn('v1.7.0-alpha.0.1320+599539dc0b9997', self.envs['E2E_OPT'])
self.assertIn('--kubernetes-anywhere-kubeadm-version gs://kubernetes-release-dev/bazel/v1.7.0-alpha.0.1320+599539dc0b9997/bin/linux/amd64/', self.envs['E2E_OPT'])
called = False
for call in self.callstack:
self.assertFalse(call.startswith('docker'))
if call == 'hack/print-workspace-status.sh':
called = True
self.assertTrue(called)

def test_kubeadm_periodic(self):
"""Make sure kubeadm periodic mode is fine overall."""
args = self.parser.parse_args(['--mode=local', '--kubeadm=periodic'])
self.assertEqual(args.mode, 'local')
self.assertEqual(args.kubeadm, 'periodic')
with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
with Stub(kubernetes_e2e, 'check_output', self.fake_output_work_status):
kubernetes_e2e.main(args)

self.assertIn('E2E_OPT', self.envs)
self.assertIn('--kubernetes-anywhere-kubeadm-version gs://kubernetes-release-dev/bazel/v1.7.0-alpha.0.1320+599539dc0b9997/bin/linux/amd64/', self.envs['E2E_OPT'])
called = False
for call in self.callstack:
self.assertFalse(call.startswith('docker'))
if call == 'hack/print-workspace-status.sh':
called = True
self.assertTrue(called)

def test_kubeadm_pull(self):
"""Make sure kubeadm pull mode is fine overall."""
args = self.parser.parse_args(['--mode=local', '--kubeadm=pull'])
self.assertEqual(args.mode, 'local')
self.assertEqual(args.kubeadm, 'pull')
fake_env = {'PULL_NUMBER': 1234, 'PULL_REFS': 'master:abcd'}
with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
with Stub(os, 'environ', fake_env):
kubernetes_e2e.main(args)

self.assertIn('E2E_OPT', self.envs)
self.assertIn('--kubernetes-anywhere-kubeadm-version gs://kubernetes-release-dev/bazel/1234/master:abcd/bin/linux/amd64/', self.envs['E2E_OPT'])

def test_kubeadm_invalid(self):
"""Make sure kubeadm invalid mode exits unsuccessfully."""
with self.assertRaises(SystemExit) as sysexit:
self.parser.parse_args(['--mode=local', '--kubeadm=deploy'])

self.assertEqual(sysexit.exception.code, 2)

class DockerTest(ScenarioTest):
"""Class for testing e2e scenario in docker mode."""
def test_docker(self):
Expand Down

0 comments on commit 1b011d1

Please sign in to comment.