Ejemplo n.º 1
0
 def test_check_leaks_false_docker(self):
     """Ensure we also set FAIL_ON_GCP_RESOURCE_LEAK when mode=docker."""
     args = kubernetes_e2e.parse_args(['--mode=docker', '--check-leaked-resources=false'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
         self.assertIn('--check-leaked-resources=false', self.callstack[-1])
         self.assertIn('-e FAIL_ON_GCP_RESOURCE_LEAK=false', self.callstack[-1])
Ejemplo n.º 2
0
    def test_aws(self):
        temp = tempfile.NamedTemporaryFile()
        args = kubernetes_e2e.parse_args([
            '--aws',
            '--cluster=foo',
            '--aws-cluster-domain=test-aws.k8s.io',
            '--aws-ssh=%s' % temp.name,
            '--aws-pub=%s' % temp.name,
            '--aws-cred=%s' % temp.name,
            ])
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        lastcall = self.callstack[-1]
        self.assertIn('kops-e2e-runner.sh', lastcall)
        self.assertIn('--kops-cluster=foo.test-aws.k8s.io', lastcall)
        self.assertIn('--kops-zones', lastcall)
        self.assertIn('--kops-state=s3://k8s-kops-jenkins/', lastcall)
        self.assertIn('--kops-nodes=4', lastcall)
        self.assertIn('--kops-ssh-key', lastcall)

        self.assertEqual(
            self.envs['JENKINS_AWS_SSH_PRIVATE_KEY_FILE'], temp.name)
        self.assertEqual(
            self.envs['JENKINS_AWS_SSH_PUBLIC_KEY_FILE'], temp.name)
        self.assertEqual(
            self.envs['JENKINS_AWS_CREDENTIALS_FILE'], temp.name)
Ejemplo n.º 3
0
 def test_check_leaks_unset(self):
     """Ensure --check-leaked-resources=true sends flag to kubetest."""
     args = kubernetes_e2e.parse_args(['--mode=local'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
         self.assertNotIn('--check-leaked-resources', self.callstack[-1])
         self.assertEquals('false', self.envs.get('FAIL_ON_GCP_RESOURCE_LEAK'))
Ejemplo n.º 4
0
 def test_updown_default(self):
     args = kubernetes_e2e.parse_args([])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertIn('--up', lastcall)
     self.assertIn('--down', lastcall)
Ejemplo n.º 5
0
 def test_migrated_kubetest_args(self):
     migrated = [
         '--stage=a-stage',
         '--stage-suffix=panda',
         '--random-flag', 'random-value',
         '--multiple-federations',
         'arg1', 'arg2',
         '--federation',
         '--kubemark',
         '--extract=this',
         '--extract=that',
         '--perf-tests',
         '--deployment=yay',
         '--save=somewhere',
         '--skew',
         '--publish=location',
         '--timeout=42m',
         '--upgrade_args=ginkgo',
         '--check-leaked-resources=true',
         '--charts',
     ]
     args = kubernetes_e2e.parse_args(['--mode=docker'] + migrated + ['--test=false'])
     self.assertEquals(migrated, args.kubetest_args)
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-2]
     for arg in migrated:
         self.assertIn(arg, lastcall)
Ejemplo n.º 6
0
 def test_updown_set(self):
     args = kubernetes_e2e.parse_args(['--mode=local', '--up=false', '--down=true'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertNotIn('--up', lastcall)
     self.assertIn('--down', lastcall)
Ejemplo n.º 7
0
 def test_extract_args(self):
     """Ensure extract flags are passed to kubetest."""
     args = self.parser.parse_args(['--extract=foo', '--extract=bar'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
         self.assertIn('--extract=foo', self.callstack[-1])
         self.assertIn('--extract=bar', self.callstack[-1])
Ejemplo n.º 8
0
    def test_kubeadm_pull(self):
        """Make sure kubeadm pull mode is fine overall."""
        args = kubernetes_e2e.parse_args([
            '--mode=local',
            '--kubeadm=pull',
            '--use-shared-build=bazel'
        ])
        self.assertEqual(args.mode, 'local')
        self.assertEqual(args.kubeadm, 'pull')
        self.assertEqual(args.use_shared_build, 'bazel')

        gcs_bucket = "gs://kubernetes-release-dev/bazel/v1.8.0-beta.1.132+599539dc0b9997"

        def fake_gcs_path(path):
            bazel_default = os.path.join(
                'gs://kubernetes-jenkins/shared-results', 'bazel-build-location.txt')
            self.assertEqual(path, bazel_default)
            return gcs_bucket
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(kubernetes_e2e, 'read_gcs_path', fake_gcs_path):
                kubernetes_e2e.main(args)

        self.assertNotIn('E2E_OPT', self.envs)
        version = '%s/bin/linux/amd64/' % gcs_bucket
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
Ejemplo n.º 9
0
 def test_env_docker(self):
     env = 'FOO=bar blatz'
     args = kubernetes_e2e.parse_args([
         '--mode=docker',
         '--env=' + env,
     ])
     kubernetes_e2e.main(args)
     self.assertIn('-e '+env, self.callstack[-2])
Ejemplo n.º 10
0
    def test_local(self):
        """Make sure local mode is fine overall."""
        args = kubernetes_e2e.parse_args()
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        self.assertNotEqual(self.envs, {})
        for call in self.callstack:
            self.assertFalse(call.startswith('docker'))
Ejemplo n.º 11
0
    def test_docker(self):
        """Make sure docker mode is fine overall."""
        args = kubernetes_e2e.parse_args(['--mode=docker'])
        self.assertEqual(args.mode, 'docker')
        with Stub(kubernetes_e2e, 'check_env', fake_bomb):
            kubernetes_e2e.main(args)

        self.assertEqual(self.envs, {})
        call = self.callstack[-2]
        self.assertTrue(call.startswith('docker'), call)
Ejemplo n.º 12
0
    def test_docker(self):
        """Make sure docker mode is fine overall."""
        args = self.parser.parse_args()
        self.assertEqual(args.mode, 'docker')
        with Stub(kubernetes_e2e, 'check_env', fake_bomb):
            kubernetes_e2e.main(args)

        self.assertEqual(self.envs, {})
        for call in self.callstack:
            self.assertTrue(call.startswith('docker'))
Ejemplo n.º 13
0
    def test_updown(self):
        """Make sure local mode is fine overall."""
        args = self.parser.parse_args(['--mode=local', '--up=false'])
        self.assertEqual(args.mode, 'local')
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        lastcall = self.callstack[-1]
        self.assertNotIn('--up', lastcall)
        self.assertIn('--down', lastcall)
Ejemplo n.º 14
0
 def test_env_local(self):
     env = 'FOO'
     value = 'BLAT'
     args = kubernetes_e2e.parse_args([
         '--mode=local',
         '--env={env}={value}'.format(env=env, value=value),
     ])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     self.assertIn(env, self.envs)
     self.assertEqual(self.envs[env], value)
Ejemplo n.º 15
0
    def test_kubeadm_pull(self):
        """Make sure kubeadm pull mode is fine overall."""
        args = kubernetes_e2e.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.assertNotIn('E2E_OPT', self.envs)
        version = 'gs://kubernetes-release-dev/bazel/1234/master:abcd/bin/linux/amd64/'
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
Ejemplo n.º 16
0
 def test_image_family(self):
     """Make sure --image-family fetches the latest image correctly."""
     args = kubernetes_e2e.parse_args([
         '--mode=local',
         '--image-family=cos-stable',
         '--image-project=cos-cloud'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         with Stub(
             kubernetes_e2e,
             'check_output',
             self.fake_output_get_latest_image):
             kubernetes_e2e.main(args)
     self.assertEqual(
         self.envs['KUBE_GCE_NODE_IMAGE'], 'cos-stable-59-9460-64-0')
     self.assertEqual(self.envs['KUBE_GCE_NODE_PROJECT'], 'cos-cloud')
Ejemplo n.º 17
0
 def test_image_family(self):
     """Make sure --image-family fetches the latest image correctly."""
     args = kubernetes_e2e.parse_args([
         '--mode=local',
         '--image-family=cos-stable',
         '--image-project=cos-cloud'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         with Stub(
             kubernetes_e2e,
             'check_output',
             self.fake_output_get_latest_image):
             kubernetes_e2e.main(args)
     self.assertEqual(
         self.envs['KUBE_GCE_NODE_IMAGE'], 'cos-stable-59-9460-64-0')
     self.assertEqual(self.envs['KUBE_GCE_NODE_PROJECT'], 'cos-cloud')
Ejemplo n.º 18
0
    def test_kubeadm(self):
        """Make sure kubeadm mode is fine overall."""
        args = self.parser.parse_args(['--mode=local', '--kubeadm'])
        self.assertEqual(args.mode, 'local')
        self.assertEqual(args.kubeadm, True)
        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'])
        called = False
        for call in self.callstack:
            self.assertFalse(call.startswith('docker'))
            if call == 'hack/print-workspace-status.sh':
                called = True
        self.assertTrue(called)
Ejemplo n.º 19
0
    def test_kubeadm_periodic(self):
        """Make sure kubeadm periodic mode is fine overall."""
        args = kubernetes_e2e.parse_args(['--kubeadm=periodic'])
        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.assertNotIn('E2E_OPT', self.envs)
        version = 'gs://kubernetes-release-dev/ci/v1.7.0-alpha.0.1320+599539dc0b9997-bazel/bin/linux/amd64/'  # pylint: disable=line-too-long
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
        called = False
        for call in self.callstack:
            self.assertFalse(call.startswith('docker'))
            if call == 'hack/print-workspace-status.sh':
                called = True
        self.assertTrue(called)
Ejemplo n.º 20
0
    def test_kubeadm_periodic(self):
        """Make sure kubeadm periodic mode is fine overall."""
        args = kubernetes_e2e.parse_args(['--kubeadm=periodic'])
        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.assertNotIn('E2E_OPT', self.envs)
        version = 'gs://kubernetes-release-dev/ci/v1.7.0-alpha.0.1320+599539dc0b9997-bazel/bin/linux/amd64/'  # pylint: disable=line-too-long
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
        called = False
        for call in self.callstack:
            self.assertFalse(call.startswith('docker'))
            if call == 'hack/print-workspace-status.sh':
                called = True
        self.assertTrue(called)
Ejemplo n.º 21
0
    def test_kubeadm_periodic_v1_6(self):
        """Make sure kubeadm periodic mode has correct version on v1.6"""
        args = kubernetes_e2e.parse_args(['--kubeadm=periodic'])
        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_v1_6):
                kubernetes_e2e.main(args)

        self.assertNotIn('E2E_OPT', self.envs)
        version = 'gs://kubernetes-release-dev/bazel/v1.6.4-beta.0.18+84febd4537dd19/build/debs/'
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
        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 = kubernetes_e2e.parse_args(['--mode=local', '--kubeadm=pull'])
        self.assertEqual(args.mode, 'local')
        self.assertEqual(args.kubeadm, 'pull')
        fake_env = {
            'SHARED_BUILD_GCS_PATH':
            'gs://kubernetes-release-dev/bazel/v1.8.0-beta.1.132+599539dc0b9997'
        }
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(os, 'environ', fake_env):
                kubernetes_e2e.main(args)

        self.assertNotIn('E2E_OPT', self.envs)
        ver = 'gs://kubernetes-release-dev/bazel/v1.8.0-beta.1.132+599539dc0b9997/bin/linux/amd64/'
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % ver,
                      self.callstack[-1])
Ejemplo n.º 23
0
    def test_kubeadm_periodic_v1_6(self):
        """Make sure kubeadm periodic mode has correct version on v1.6"""
        args = kubernetes_e2e.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_v1_6):
                kubernetes_e2e.main(args)

        self.assertNotIn('E2E_OPT', self.envs)
        version = 'gs://kubernetes-release-dev/bazel/v1.6.4-beta.0.18+84febd4537dd19/build/debs/'
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
        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_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, '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('--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)
Ejemplo n.º 25
0
    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, '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('--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)
Ejemplo n.º 26
0
    def test_kubeadm(self):
        """Make sure kubeadm mode is fine overall."""
        args = self.parser.parse_args(['--mode=local', '--kubeadm'])
        self.assertEqual(args.mode, 'local')
        self.assertEqual(args.kubeadm, True)
        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'])
        called = False
        for call in self.callstack:
            self.assertFalse(call.startswith('docker'))
            if call == 'hack/print-workspace-status.sh':
                called = True
        self.assertTrue(called)
Ejemplo n.º 27
0
    def test_kops_gce(self):
        temp = tempfile.NamedTemporaryFile()
        args = kubernetes_e2e.parse_args([
            '--provider=gce',
            '--deployment=kops',
            '--cluster=foo.example.com',
            '--gce-ssh=%s' % temp.name,
            '--gce-pub=%s' % temp.name,
            ])
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        lastcall = self.callstack[-1]
        self.assertIn('kubetest', lastcall)
        self.assertIn('--provider=gce', lastcall)
        self.assertIn('--deployment=kops', lastcall)
        self.assertIn('--kops-cluster=foo.example.com', lastcall)
        self.assertIn('--kops-zones', lastcall)
        self.assertIn('--kops-state=gs://k8s-kops-gce/', lastcall)
        self.assertIn('--kops-nodes=4', lastcall)
        self.assertIn('--kops-ssh-key', lastcall)
Ejemplo n.º 28
0
    def test_kops_gce(self):
        temp = tempfile.NamedTemporaryFile()
        args = kubernetes_e2e.parse_args([
            '--provider=gce',
            '--deployment=kops',
            '--cluster=foo.example.com',
            '--gce-ssh=%s' % temp.name,
            '--gce-pub=%s' % temp.name,
        ])
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        lastcall = self.callstack[-1]
        self.assertIn('kubetest', lastcall)
        self.assertIn('--provider=gce', lastcall)
        self.assertIn('--deployment=kops', lastcall)
        self.assertIn('--kops-cluster=foo.example.com', lastcall)
        self.assertIn('--kops-zones', lastcall)
        self.assertIn('--kops-state=gs://k8s-kops-gce/', lastcall)
        self.assertIn('--kops-nodes=4', lastcall)
        self.assertIn('--kops-ssh-key', lastcall)
Ejemplo n.º 29
0
    def test_kubeadm_pull(self):
        """Make sure kubeadm pull mode is fine overall."""
        args = kubernetes_e2e.parse_args([
            '--kubeadm=pull',
            '--use-shared-build=bazel'
        ])
        self.assertEqual(args.kubeadm, 'pull')
        self.assertEqual(args.use_shared_build, 'bazel')

        gcs_bucket = "gs://kubernetes-release-dev/bazel/v1.8.0-beta.1.132+599539dc0b9997"

        def fake_gcs_path(path):
            bazel_default = os.path.join(
                'gs://kubernetes-jenkins/shared-results', 'bazel-build-location.txt')
            self.assertEqual(path, bazel_default)
            return gcs_bucket
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(kubernetes_e2e, 'read_gcs_path', fake_gcs_path):
                kubernetes_e2e.main(args)

        self.assertNotIn('E2E_OPT', self.envs)
        version = '%s/bin/linux/amd64/' % gcs_bucket
        self.assertIn('--kubernetes-anywhere-kubeadm-version=%s' % version, self.callstack[-1])
Ejemplo n.º 30
0
    def test_kops_aws(self):
        temp = tempfile.NamedTemporaryFile()
        args = kubernetes_e2e.parse_args([
            '--provider=aws',
            '--deployment=kops',
            '--cluster=foo.example.com',
            '--aws-ssh=%s' % temp.name,
            '--aws-pub=%s' % temp.name,
            '--aws-cred=%s' % temp.name,
            ])
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            kubernetes_e2e.main(args)

        lastcall = self.callstack[-1]
        self.assertIn('kubetest', lastcall)
        self.assertIn('--provider=aws', lastcall)
        self.assertIn('--deployment=kops', lastcall)
        self.assertIn('--kops-cluster=foo.example.com', lastcall)
        self.assertIn('--kops-zones', lastcall)
        self.assertIn('--kops-state=s3://k8s-kops-jenkins/', lastcall)
        self.assertIn('--kops-nodes=4', lastcall)
        self.assertIn('--kops-ssh-key', lastcall)
        self.assertIn('kubetest', lastcall)
        self.assertNotIn('kops-e2e-runner.sh', lastcall)
Ejemplo n.º 31
0
 def test_migrated_kubetest_args(self):
     migrated = [
         '--stage-suffix=panda',
         '--random-flag',
         'random-value',
         '--multiple-federations',
         'arg1',
         'arg2',
         '--federation',
         '--kubemark',
         '--extract=this',
         '--extract=that',
         '--perf-tests',
         '--save=somewhere',
         '--skew',
         '--publish=location',
         '--timeout=42m',
         '--upgrade_args=ginkgo',
         '--check-leaked-resources=true',
         '--charts',
     ]
     explicit_passthrough_args = [
         '--deployment=yay',
         '--provider=gce',
     ]
     args = kubernetes_e2e.parse_args(['--mode=docker'] + migrated +
                                      explicit_passthrough_args +
                                      ['--test=false'])
     self.assertEquals(migrated, args.kubetest_args)
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-2]
     for arg in migrated:
         self.assertIn(arg, lastcall)
     for arg in explicit_passthrough_args:
         self.assertIn(arg, lastcall)
Ejemplo n.º 32
0
    def test_use_shared_build(self):
        # normal path
        args = kubernetes_e2e.parse_args(['--use-shared-build=bazel'])

        def expect_bazel_gcs(path):
            bazel_default = os.path.join(
                'gs://kubernetes-jenkins/shared-results',
                'bazel-build-location.txt')
            self.assertEqual(path, bazel_default)
            return always_kubernetes()

        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(kubernetes_e2e, 'read_gcs_path', expect_bazel_gcs):
                with Stub(time, 'sleep', fake_pass):
                    kubernetes_e2e.main(args)
        lastcall = self.callstack[-1]
        self.assertIn('--extract=kubernetes', lastcall)
        # normal path, not bazel
        args = kubernetes_e2e.parse_args(['--use-shared-build'])

        def expect_normal_gcs(path):
            bazel_default = os.path.join(
                'gs://kubernetes-jenkins/shared-results', 'build-location.txt')
            self.assertEqual(path, bazel_default)
            return always_kubernetes()

        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(kubernetes_e2e, 'read_gcs_path', expect_normal_gcs):
                kubernetes_e2e.main(args)
        lastcall = self.callstack[-1]
        self.assertIn('--extract=kubernetes', lastcall)
        # test failure to read shared path from GCS
        with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
            with Stub(kubernetes_e2e, 'read_gcs_path', raise_urllib2_error):
                with Stub(os, 'getcwd', always_kubernetes):
                    with Stub(time, 'sleep', fake_pass):
                        try:
                            kubernetes_e2e.main(args)
                        except RuntimeError as err:
                            if not err.message.startswith(
                                    'Failed to get shared build location'):
                                raise err
Ejemplo n.º 33
0
 def test_use_shared_build(self):
     # normal path
     args = kubernetes_e2e.parse_args([
         '--use-shared-build=bazel'
     ])
     def expect_bazel_gcs(path):
         bazel_default = os.path.join(
             'gs://kubernetes-jenkins/shared-results', 'bazel-build-location.txt')
         self.assertEqual(path, bazel_default)
         return always_kubernetes()
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         with Stub(kubernetes_e2e, 'read_gcs_path', expect_bazel_gcs):
             with Stub(time, 'sleep', fake_pass):
                 kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertIn('--extract=kubernetes', lastcall)
     # normal path, not bazel
     args = kubernetes_e2e.parse_args([
         '--use-shared-build'
     ])
     def expect_normal_gcs(path):
         bazel_default = os.path.join(
             'gs://kubernetes-jenkins/shared-results', 'build-location.txt')
         self.assertEqual(path, bazel_default)
         return always_kubernetes()
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         with Stub(kubernetes_e2e, 'read_gcs_path', expect_normal_gcs):
             kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertIn('--extract=kubernetes', lastcall)
     # test failure to read shared path from GCS
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         with Stub(kubernetes_e2e, 'read_gcs_path', raise_urllib2_error):
             with Stub(os, 'getcwd', always_kubernetes):
                 with Stub(time, 'sleep', fake_pass):
                     try:
                         kubernetes_e2e.main(args)
                     except RuntimeError as err:
                         if not err.message.startswith('Failed to get shared build location'):
                             raise err
Ejemplo n.º 34
0
 def test_gcp_network(self):
     args = kubernetes_e2e.parse_args(['--mode=local', '--cluster=test'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertIn('--gcp-network=test', lastcall)
Ejemplo n.º 35
0
 def test_check_leaks_unset(self):
     """Ensure --check-leaked-resources=true sends flag to kubetest."""
     args = kubernetes_e2e.parse_args(['--mode=local'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
         self.assertNotIn('--check-leaked-resources', self.callstack[-1])
Ejemplo n.º 36
0
 def test_gcp_network(self):
     args = kubernetes_e2e.parse_args(['--mode=local', '--cluster=test'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
     lastcall = self.callstack[-1]
     self.assertIn('--gcp-network=test', lastcall)
Ejemplo n.º 37
0
 def test_check_leaks_unset(self):
     """Ensure --check-leaked-resources=true sends flag to kubetest."""
     args = kubernetes_e2e.parse_args(['--mode=local'])
     with Stub(kubernetes_e2e, 'check_env', self.fake_check_env):
         kubernetes_e2e.main(args)
         self.assertNotIn('--check-leaked-resources', self.callstack[-1])