mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
centralise testing api-server & remove custom implementation
Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com>
This commit is contained in:
@@ -90,6 +90,7 @@ filegroup(
|
||||
"//test/acme/dns:all-srcs",
|
||||
"//test/e2e:all-srcs",
|
||||
"//test/integration:all-srcs",
|
||||
"//test/internal/apiserver:all-srcs",
|
||||
"//test/unit/coreclients:all-srcs",
|
||||
"//test/unit/gen:all-srcs",
|
||||
"//test/unit/listers:all-srcs",
|
||||
|
||||
@@ -24885,215 +24885,6 @@ third-party archives.
|
||||
================================================================================
|
||||
|
||||
|
||||
================================================================================
|
||||
= vendor/sigs.k8s.io/testing_frameworks licensed under: =
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 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.
|
||||
|
||||
= vendor/sigs.k8s.io/testing_frameworks/LICENSE 79e0be350ab05c8958665a59f9445789
|
||||
================================================================================
|
||||
|
||||
|
||||
================================================================================
|
||||
= vendor/sigs.k8s.io/yaml licensed under: =
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ require (
|
||||
rsc.io/letsencrypt v0.0.3 // indirect
|
||||
sigs.k8s.io/controller-runtime v0.9.2
|
||||
sigs.k8s.io/controller-tools v0.6.0
|
||||
sigs.k8s.io/testing_frameworks v0.1.2
|
||||
sigs.k8s.io/yaml v1.2.0
|
||||
software.sslmate.com/src/go-pkcs12 v0.0.0-20200830195227-52f69702a001
|
||||
)
|
||||
|
||||
@@ -484,7 +484,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1 h1:ocYkMQY5RrXTYgXl7ICpV0IXwlEQGwKIsery4gyXa1U=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -1177,7 +1176,6 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180117170059-2c42eef0765b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -1242,7 +1240,6 @@ golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20171227012246-e19ae1496984/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
@@ -1426,7 +1423,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.0.0/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@@ -1544,8 +1540,6 @@ sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnM
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0 h1:C4r9BgJ98vrKnnVCjwCSXcWjWe0NKcUQkmzDXZXGwH8=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/testing_frameworks v0.1.2 h1:vK0+tvjF0BZ/RYFeZ1E6BYBwHJJXhjuZ3TdsEKH+UQM=
|
||||
sigs.k8s.io/testing_frameworks v0.1.2/go.mod h1:ToQrwSC3s8Xf/lADdZp3Mktcql9CG0UAmdJG9th5i0w=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
|
||||
@@ -19,14 +19,14 @@ go_library(
|
||||
"//pkg/acme/webhook:go_default_library",
|
||||
"//pkg/acme/webhook/apis/acme/v1alpha1:go_default_library",
|
||||
"//pkg/issuer/acme/dns/util:go_default_library",
|
||||
"//test/internal/apiserver:go_default_library",
|
||||
"@com_github_miekg_dns//:go_default_library",
|
||||
"@io_k8s_api//core/v1:go_default_library",
|
||||
"@io_k8s_apiextensions_apiserver//pkg/apis/apiextensions/v1beta1:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/util/wait:go_default_library",
|
||||
"@io_k8s_client_go//kubernetes:go_default_library",
|
||||
"@io_k8s_client_go//rest:go_default_library",
|
||||
"@io_k8s_sigs_testing_frameworks//integration:go_default_library",
|
||||
"@io_k8s_sigs_controller_runtime//pkg/envtest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
+18
-61
@@ -23,13 +23,12 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
"k8s.io/client-go/rest"
|
||||
"sigs.k8s.io/testing_frameworks/integration"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/acme/webhook"
|
||||
"github.com/jetstack/cert-manager/test/internal/apiserver"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -52,7 +51,6 @@ type fixture struct {
|
||||
strictMode bool
|
||||
useAuthoritative *bool
|
||||
kubectlManifestsPath string
|
||||
binariesPath string
|
||||
|
||||
// testDNSServer is the address:port of the DNS server to send requests to
|
||||
// when validating that records are set as expected.
|
||||
@@ -72,37 +70,15 @@ type fixture struct {
|
||||
// Default: "123d=="
|
||||
dnsChallengeKey string
|
||||
|
||||
// controlPlane is a reference to the control plane that is used to run the
|
||||
// test suite.
|
||||
// It is constructed when a Run* method is called.
|
||||
controlPlane *integration.ControlPlane
|
||||
restConfig *rest.Config
|
||||
clientset kubernetes.Interface
|
||||
kubectl *integration.KubeCtl
|
||||
setupLock sync.Mutex
|
||||
setupLock sync.Mutex
|
||||
environment *envtest.Environment
|
||||
clientset kubernetes.Interface
|
||||
|
||||
pollInterval time.Duration
|
||||
propagationLimit time.Duration
|
||||
}
|
||||
|
||||
var DefaultKubeAPIServerFlags = []string{
|
||||
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
|
||||
"--cert-dir={{ .CertDir }}",
|
||||
"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
|
||||
"--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
|
||||
"--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
|
||||
"--admission-control=AlwaysAdmit",
|
||||
}
|
||||
|
||||
// Setup will set up the test fixture by running kube-apiserver and etcd.
|
||||
// One instance of the apiserver and etcd will be shared throughout all of the
|
||||
// suite.
|
||||
// The first time this function is called, the function that is returned will
|
||||
// be the control plane's Stop function. Subsequent calls to setup will return
|
||||
// a function that does nothing. This allows all the Run* functions to call
|
||||
// setup, and defer cleaning up the fixture, but only the first 'entrypoint'
|
||||
// Run function will actually clean up the apiserver.
|
||||
func (f *fixture) setup(t *testing.T) func() error {
|
||||
func (f *fixture) setup(t *testing.T) func() {
|
||||
f.setupLock.Lock()
|
||||
defer f.setupLock.Unlock()
|
||||
|
||||
@@ -110,40 +86,21 @@ func (f *fixture) setup(t *testing.T) func() error {
|
||||
t.Fatalf("error validating test fixture configuration: %v", err)
|
||||
}
|
||||
|
||||
if f.controlPlane != nil {
|
||||
return func() error { return nil }
|
||||
env, stopFunc := apiserver.RunBareControlPlane(t)
|
||||
f.environment = env
|
||||
|
||||
cl, err := kubernetes.NewForConfig(env.Config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f.controlPlane = &integration.ControlPlane{}
|
||||
f.controlPlane.APIServer = &integration.APIServer{
|
||||
Args: DefaultKubeAPIServerFlags,
|
||||
Path: f.binariesPath + "/kube-apiserver",
|
||||
}
|
||||
f.controlPlane.Etcd = &integration.Etcd{
|
||||
Path: f.binariesPath + "/etcd",
|
||||
}
|
||||
if err := f.controlPlane.Start(); err != nil {
|
||||
t.Fatalf("error starting apiserver: %v", err)
|
||||
}
|
||||
t.Logf("started apiserver on %q", f.controlPlane.APIURL())
|
||||
// Create the *rest.Config for creating new clients
|
||||
f.restConfig = &rest.Config{
|
||||
Host: f.controlPlane.APIURL().Host,
|
||||
// gotta go fast during tests -- we don't really care about overwhelming our test API server
|
||||
QPS: 1000.0,
|
||||
Burst: 2000.0,
|
||||
}
|
||||
var err error
|
||||
if f.clientset, err = kubernetes.NewForConfig(f.restConfig); err != nil {
|
||||
t.Fatalf("error constructing clientset: %v", err)
|
||||
}
|
||||
f.kubectl = f.controlPlane.KubeCtl()
|
||||
f.kubectl.Path = f.binariesPath + "/kubectl"
|
||||
f.clientset = cl
|
||||
|
||||
stopCh := make(chan struct{})
|
||||
f.testSolver.Initialize(f.restConfig, stopCh)
|
||||
return func() error {
|
||||
f.testSolver.Initialize(env.Config, stopCh)
|
||||
|
||||
return func() {
|
||||
close(stopCh)
|
||||
return f.controlPlane.Stop()
|
||||
stopFunc()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -58,12 +57,6 @@ func applyDefaults(f *fixture) {
|
||||
if f.dnsChallengeKey == "" {
|
||||
f.dnsChallengeKey = "123d=="
|
||||
}
|
||||
runfiles := os.Getenv("TEST_SRCDIR")
|
||||
if f.binariesPath == "" {
|
||||
if runfiles != "" {
|
||||
f.binariesPath = runfiles + "/com_github_jetstack_cert_manager/hack/bin"
|
||||
}
|
||||
}
|
||||
if f.jsonConfig == nil {
|
||||
if f.kubectlManifestsPath != "" {
|
||||
d, err := ioutil.ReadFile(f.kubectlManifestsPath + "/config.json")
|
||||
@@ -91,9 +84,6 @@ func validate(f *fixture) error {
|
||||
if f.resolvedZone == "" {
|
||||
errs = append(errs, fmt.Errorf("resolvedZone must be provided"))
|
||||
}
|
||||
if f.binariesPath == "" {
|
||||
errs = append(errs, fmt.Errorf("binariesPath must be provided"))
|
||||
}
|
||||
if f.jsonConfig == nil {
|
||||
errs = append(errs, fmt.Errorf("jsonConfig must be provided"))
|
||||
}
|
||||
@@ -159,12 +149,6 @@ func SetDNSServer(s string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func SetBinariesPath(s string) Option {
|
||||
return func(f *fixture) {
|
||||
f.binariesPath = s
|
||||
}
|
||||
}
|
||||
|
||||
func SetPollInterval(d time.Duration) Option {
|
||||
return func(f *fixture) {
|
||||
f.pollInterval = d
|
||||
|
||||
@@ -60,7 +60,7 @@ func (f *fixture) setupNamespace(t *testing.T, name string) (string, func()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, _, err = f.kubectl.Run("apply", "--namespace", name, "-f", path)
|
||||
_, _, err = f.environment.ControlPlane.KubeCtl().Run("apply", "--namespace", name, "-f", path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ go_library(
|
||||
srcs = [
|
||||
"apiserver.go",
|
||||
"helpers.go",
|
||||
"paths.go",
|
||||
],
|
||||
data = [
|
||||
"//deploy/crds:crds.yaml",
|
||||
@@ -22,6 +21,7 @@ go_library(
|
||||
"//pkg/client/clientset/versioned:go_default_library",
|
||||
"//pkg/client/informers/externalversions:go_default_library",
|
||||
"//pkg/controller:go_default_library",
|
||||
"//test/internal/apiserver:go_default_library",
|
||||
"@io_k8s_api//admissionregistration/v1beta1:go_default_library",
|
||||
"@io_k8s_api//core/v1:go_default_library",
|
||||
"@io_k8s_apiextensions_apiserver//pkg/apis/apiextensions:go_default_library",
|
||||
@@ -42,7 +42,6 @@ go_library(
|
||||
"@io_k8s_client_go//tools/record:go_default_library",
|
||||
"@io_k8s_kubectl//pkg/util/openapi:go_default_library",
|
||||
"@io_k8s_sigs_controller_runtime//pkg/client:go_default_library",
|
||||
"@io_k8s_sigs_controller_runtime//pkg/envtest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -36,33 +36,18 @@ import (
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/rest"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||
|
||||
webhooktesting "github.com/jetstack/cert-manager/cmd/webhook/app/testing"
|
||||
"github.com/jetstack/cert-manager/pkg/api"
|
||||
apitesting "github.com/jetstack/cert-manager/pkg/api/testing"
|
||||
"github.com/jetstack/cert-manager/test/internal/apiserver"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Set environment variables for controller-runtime's envtest package.
|
||||
// This is done once as we cannot scope environment variables to a single
|
||||
// invocation of RunControlPlane due to envtest's design.
|
||||
setUpEnvTestEnv()
|
||||
}
|
||||
|
||||
type StopFunc func()
|
||||
|
||||
func RunControlPlane(t *testing.T) (*rest.Config, StopFunc) {
|
||||
// Here we start the API server so its address can be given to the webhook on
|
||||
// start. We then restart the API with the CRDs in the webhook.
|
||||
env := &envtest.Environment{
|
||||
AttachControlPlaneOutput: false,
|
||||
}
|
||||
|
||||
config, err := env.Start()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to start control plane: %v", err)
|
||||
}
|
||||
env, stopFn := apiserver.RunBareControlPlane(t)
|
||||
config := env.Config
|
||||
|
||||
if err := env.Stop(); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -77,9 +62,8 @@ func RunControlPlane(t *testing.T) (*rest.Config, StopFunc) {
|
||||
patchCRDConversion(crds, webhookOpts.URL, webhookOpts.CAPEM)
|
||||
|
||||
env.CRDs = crdsToRuntimeObjects(crds)
|
||||
env.Config = config
|
||||
|
||||
config, err = env.Start()
|
||||
config, err := env.Start()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to start control plane: %v", err)
|
||||
}
|
||||
@@ -103,9 +87,7 @@ func RunControlPlane(t *testing.T) (*rest.Config, StopFunc) {
|
||||
|
||||
return config, func() {
|
||||
defer stopWebhook()
|
||||
if err := env.Stop(); err != nil {
|
||||
t.Logf("failed to shut down control plane, not failing test: %v", err)
|
||||
}
|
||||
stopFn()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"apiserver.go",
|
||||
"paths.go",
|
||||
],
|
||||
importpath = "github.com/jetstack/cert-manager/test/internal/apiserver",
|
||||
visibility = ["//test:__subpackages__"],
|
||||
deps = ["@io_k8s_sigs_controller_runtime//pkg/envtest:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2021 The cert-manager 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 apiserver
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Set environment variables for controller-runtime's envtest package.
|
||||
// This is done once as we cannot scope environment variables to a single
|
||||
// invocation of RunControlPlane due to envtest's design.
|
||||
setUpEnvTestEnv()
|
||||
}
|
||||
|
||||
type StopFunc func()
|
||||
|
||||
func RunBareControlPlane(t *testing.T) (*envtest.Environment, StopFunc) {
|
||||
// Here we start the API server so its address can be given to the webhook on
|
||||
// start. We then restart the API with the CRDs in the webhook.
|
||||
env := &envtest.Environment{
|
||||
AttachControlPlaneOutput: true,
|
||||
}
|
||||
|
||||
if _, err := env.Start(); err != nil {
|
||||
t.Fatalf("failed to start control plane: %v", err)
|
||||
}
|
||||
|
||||
return env, func() {
|
||||
if err := env.Stop(); err != nil {
|
||||
t.Logf("failed to shut down control plane, not failing test: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2020 The cert-manager Authors.
|
||||
Copyright 2021 The cert-manager Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package framework
|
||||
package apiserver
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -38,7 +38,7 @@ func maybeSetEnv(key, bin string, path ...string) {
|
||||
p, err := getPath(bin, path...)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf(`Failed to find integration test dependency %q.
|
||||
Either re-run this test using "bazel test //test/integration/{name}" or set the %s environment variable.`, bin, key))
|
||||
Either re-run this test or set the %s environment variable.`, bin, key))
|
||||
}
|
||||
os.Setenv(key, p)
|
||||
}
|
||||
Reference in New Issue
Block a user