Merge pull request #1172 from munnerz/e2e-explore
Save global addon logs as CI artifacts & fixup logging
This commit is contained in:
commit
ac8bd61da2
@ -20,6 +20,7 @@ go_library(
|
||||
deps = [
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/addon:go_default_library",
|
||||
"//test/e2e/framework/log:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
],
|
||||
)
|
||||
@ -54,6 +55,7 @@ filegroup(
|
||||
":package-srcs",
|
||||
"//test/e2e/framework:all-srcs",
|
||||
"//test/e2e/suite:all-srcs",
|
||||
"//test/e2e/util:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
|
||||
@ -17,10 +17,15 @@ limitations under the License.
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/log"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -49,7 +54,7 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
|
||||
}
|
||||
})
|
||||
|
||||
var globalLogs string
|
||||
var globalLogs map[string]string
|
||||
|
||||
var _ = ginkgo.SynchronizedAfterSuite(func() {},
|
||||
func() {
|
||||
@ -57,7 +62,23 @@ var _ = ginkgo.SynchronizedAfterSuite(func() {},
|
||||
var err error
|
||||
globalLogs, err = addon.GlobalLogs()
|
||||
if err != nil {
|
||||
ginkgo.GinkgoWriter.Write([]byte("Failed to retrieve global addon logs: " + err.Error()))
|
||||
log.Logf("Failed to retrieve global addon logs: " + err.Error())
|
||||
}
|
||||
|
||||
for k, v := range globalLogs {
|
||||
outPath := path.Join(framework.DefaultConfig.Ginkgo.ReportDirectory, "logs", k)
|
||||
// Create a directory for the file if needed
|
||||
err := os.MkdirAll(path.Dir(outPath), 0755)
|
||||
if err != nil {
|
||||
log.Logf("Failed to create directory for logs: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(outPath, []byte(v), 0644)
|
||||
if err != nil {
|
||||
log.Logf("Failed to write log file: %v", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
ginkgo.By("Cleaning up the provisioned globals")
|
||||
|
||||
@ -19,7 +19,6 @@ package e2e
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
@ -74,9 +73,5 @@ func TestE2E(t *testing.T) {
|
||||
ginkgoconfig.GinkgoConfig.ParallelNode))))
|
||||
}
|
||||
|
||||
if !ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "cert-manager e2e suite", r) {
|
||||
if len(globalLogs) > 0 {
|
||||
log.Printf("Test suite failed, global addon logs: \n%v", globalLogs)
|
||||
}
|
||||
}
|
||||
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "cert-manager e2e suite", r)
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ go_library(
|
||||
"//test/e2e/framework/addon/nginxingress:go_default_library",
|
||||
"//test/e2e/framework/addon/tiller:go_default_library",
|
||||
"//test/e2e/framework/config:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//test/e2e/framework/log:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@ -113,6 +113,6 @@ func (p *Certmanager) SupportsGlobal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Certmanager) Logs() (string, error) {
|
||||
func (p *Certmanager) Logs() (map[string]string, error) {
|
||||
return p.chart.Logs()
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"path"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -247,15 +247,17 @@ func (c *Chart) SupportsGlobal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Chart) Logs() (string, error) {
|
||||
func (c *Chart) Logs() (map[string]string, error) {
|
||||
kc := c.Tiller.Base.Details().KubeClient
|
||||
pods, err := kc.CoreV1().Pods(c.Namespace).List(metav1.ListOptions{LabelSelector: "release=" + c.ReleaseName})
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
builder := strings.Builder{}
|
||||
out := make(map[string]string)
|
||||
for _, pod := range pods.Items {
|
||||
// Only grab logs from the first container in the pod
|
||||
// TODO: grab logs from all containers
|
||||
containerName := pod.Spec.Containers[0].Name
|
||||
resp := kc.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{
|
||||
Container: containerName,
|
||||
@ -263,22 +265,16 @@ func (c *Chart) Logs() (string, error) {
|
||||
|
||||
err := resp.Error()
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logs, err := resp.Raw()
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = builder.WriteString(fmt.Sprintf("Pod logs for %s:\n", pod.Name))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
_, err = builder.Write(logs)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
outPath := path.Join(c.Namespace, pod.Name)
|
||||
out[outPath] = string(logs)
|
||||
}
|
||||
return builder.String(), nil
|
||||
return out, nil
|
||||
}
|
||||
|
||||
@ -18,9 +18,7 @@ package addon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/base"
|
||||
@ -28,6 +26,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/nginxingress"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/config"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/log"
|
||||
)
|
||||
|
||||
type Addon interface {
|
||||
@ -120,26 +119,30 @@ func SetupGlobals(cfg *config.Config) error {
|
||||
}
|
||||
|
||||
type loggableAddon interface {
|
||||
Logs() (string, error)
|
||||
Logs() (map[string]string, error)
|
||||
}
|
||||
|
||||
func GlobalLogs() (string, error) {
|
||||
b := &strings.Builder{}
|
||||
func GlobalLogs() (map[string]string, error) {
|
||||
out := make(map[string]string)
|
||||
for _, p := range provisioned {
|
||||
if p, ok := p.(loggableAddon); ok {
|
||||
l, err := p.Logs()
|
||||
p, ok := p.(loggableAddon)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
l, err := p.Logs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = b.WriteString(fmt.Sprintf("Got pods logs for addon: \n%s\n\n", l))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// TODO: namespace logs from each addon to their addon type to avoid
|
||||
// conflicts. Realistically, it's unlikely a conflict will occur though
|
||||
// so this will probably be fine for now.
|
||||
for k, v := range l {
|
||||
out[k] = v
|
||||
}
|
||||
}
|
||||
return b.String(), nil
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DeprovisionGlobals deprovisions all of the global addons.
|
||||
@ -147,7 +150,7 @@ func GlobalLogs() (string, error) {
|
||||
// all global addons are cleaned up after a run.
|
||||
func DeprovisionGlobals(cfg *config.Config) error {
|
||||
if !cfg.Cleanup {
|
||||
glog.Infof("Skipping deprovisioning as cleanup set to false.")
|
||||
log.Logf("Skipping deprovisioning as cleanup set to false.")
|
||||
return nil
|
||||
}
|
||||
var errs []error
|
||||
|
||||
@ -144,7 +144,7 @@ func (n *Nginx) SupportsGlobal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (n *Nginx) Logs() (string, error) {
|
||||
func (n *Nginx) Logs() (map[string]string, error) {
|
||||
return n.chart.Logs()
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +102,6 @@ func (p *Pebble) SupportsGlobal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Pebble) Logs() (string, error) {
|
||||
func (p *Pebble) Logs() (map[string]string, error) {
|
||||
return p.chart.Logs()
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ func (v *Vault) SupportsGlobal() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (v *Vault) Logs() (string, error) {
|
||||
func (v *Vault) Logs() (map[string]string, error) {
|
||||
return v.chart.Logs()
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ limitations under the License.
|
||||
package framework
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -36,6 +35,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/config"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/helper"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/log"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/util/errors"
|
||||
)
|
||||
@ -115,6 +115,8 @@ func (f *Framework) BeforeEach() {
|
||||
f.Namespace, err = f.CreateKubeNamespace(f.BaseName)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
By("Using the namespace " + f.Namespace.Name)
|
||||
|
||||
By("Building a ResourceQuota api object")
|
||||
_, err = f.CreateKubeResourceQuota()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -142,7 +144,8 @@ func (f *Framework) printAddonLogs() {
|
||||
l, err := a.Logs()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
GinkgoWriter.Write([]byte(fmt.Sprintf("Got pod logs for addon: \n%s", l)))
|
||||
// TODO: replace with writing logs to a file
|
||||
log.Logf("Got pod logs for addon: \n%s", l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ go_library(
|
||||
"//test/e2e/framework/addon/pebble:go_default_library",
|
||||
"//test/e2e/framework/addon/tiller:go_default_library",
|
||||
"//test/e2e/suite/issuers/acme/certificate:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
||||
@ -17,7 +17,7 @@ go_library(
|
||||
"//test/e2e/framework/addon/pebble:go_default_library",
|
||||
"//test/e2e/framework/addon/tiller:go_default_library",
|
||||
"//test/e2e/suite/issuers/acme/dnsproviders:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//test/util/generate:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
|
||||
@ -29,7 +29,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/e2e/suite/issuers/acme/dnsproviders"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
type dns01Provider interface {
|
||||
|
||||
@ -30,7 +30,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/pebble"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
const invalidACMEURL = "http://not-a-real-acme-url.com"
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/pebble"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
const invalidACMEURL = "http://not-a-real-acme-url.com"
|
||||
|
||||
@ -15,7 +15,7 @@ go_library(
|
||||
"//pkg/util:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/addon:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
cmutil "github.com/jetstack/cert-manager/pkg/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
var _ = framework.CertManagerDescribe("CA ClusterIssuer", func() {
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
var _ = framework.CertManagerDescribe("CA Issuer", func() {
|
||||
|
||||
@ -9,7 +9,7 @@ go_library(
|
||||
deps = [
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ go_library(
|
||||
"//test/e2e/framework/addon/tiller:go_default_library",
|
||||
"//test/e2e/framework/addon/vault:go_default_library",
|
||||
"//test/e2e/suite/issuers/vault/certificate:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
],
|
||||
|
||||
@ -14,7 +14,7 @@ go_library(
|
||||
"//test/e2e/framework:go_default_library",
|
||||
"//test/e2e/framework/addon/tiller:go_default_library",
|
||||
"//test/e2e/framework/addon/vault:go_default_library",
|
||||
"//test/util:go_default_library",
|
||||
"//test/e2e/util:go_default_library",
|
||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
vaultaddon "github.com/jetstack/cert-manager/test/e2e/framework/addon/vault"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
vaultaddon "github.com/jetstack/cert-manager/test/e2e/framework/addon/vault"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
var _ = framework.CertManagerDescribe("Vault Certificate (AppRole with a custom mount path)", func() {
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/addon/tiller"
|
||||
vaultaddon "github.com/jetstack/cert-manager/test/e2e/framework/addon/vault"
|
||||
"github.com/jetstack/cert-manager/test/util"
|
||||
"github.com/jetstack/cert-manager/test/e2e/util"
|
||||
)
|
||||
|
||||
var _ = framework.CertManagerDescribe("Vault Issuer", func() {
|
||||
|
||||
39
test/e2e/util/BUILD.bazel
Normal file
39
test/e2e/util/BUILD.bazel
Normal file
@ -0,0 +1,39 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["util.go"],
|
||||
importpath = "github.com/jetstack/cert-manager/test/e2e/util",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/client/clientset/versioned/scheme:go_default_library",
|
||||
"//pkg/client/clientset/versioned/typed/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/util:go_default_library",
|
||||
"//pkg/util/pki:go_default_library",
|
||||
"//test/e2e/framework/log:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1: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"],
|
||||
)
|
||||
@ -25,7 +25,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
intscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
|
||||
"k8s.io/api/core/v1"
|
||||
extv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
@ -42,6 +41,7 @@ import (
|
||||
clientset "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/typed/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
"github.com/jetstack/cert-manager/pkg/util/pki"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/log"
|
||||
)
|
||||
|
||||
func CertificateOnlyValidForDomains(cert *x509.Certificate, commonName string, dnsNames ...string) bool {
|
||||
@ -52,7 +52,7 @@ func CertificateOnlyValidForDomains(cert *x509.Certificate, commonName string, d
|
||||
}
|
||||
|
||||
func WaitForIssuerStatusFunc(client clientset.IssuerInterface, name string, fn func(*v1alpha1.Issuer) (bool, error)) error {
|
||||
return wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout,
|
||||
return wait.PollImmediate(500*time.Millisecond, time.Minute,
|
||||
func() (bool, error) {
|
||||
issuer, err := client.Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@ -65,9 +65,9 @@ func WaitForIssuerStatusFunc(client clientset.IssuerInterface, name string, fn f
|
||||
// WaitForIssuerCondition waits for the status of the named issuer to contain
|
||||
// a condition whose type and status matches the supplied one.
|
||||
func WaitForIssuerCondition(client clientset.IssuerInterface, name string, condition v1alpha1.IssuerCondition) error {
|
||||
pollErr := wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout,
|
||||
pollErr := wait.PollImmediate(500*time.Millisecond, time.Minute,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for issuer %v condition %#v", name, condition)
|
||||
log.Logf("Waiting for issuer %v condition %#v", name, condition)
|
||||
issuer, err := client.Get(name, metav1.GetOptions{})
|
||||
if nil != err {
|
||||
return false, fmt.Errorf("error getting Issuer %q: %v", name, err)
|
||||
@ -103,9 +103,9 @@ func wrapErrorWithIssuerStatusCondition(client clientset.IssuerInterface, pollEr
|
||||
// WaitForClusterIssuerCondition waits for the status of the named issuer to contain
|
||||
// a condition whose type and status matches the supplied one.
|
||||
func WaitForClusterIssuerCondition(client clientset.ClusterIssuerInterface, name string, condition v1alpha1.IssuerCondition) error {
|
||||
pollErr := wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout,
|
||||
pollErr := wait.PollImmediate(500*time.Millisecond, time.Minute,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for clusterissuer %v condition %#v", name, condition)
|
||||
log.Logf("Waiting for clusterissuer %v condition %#v", name, condition)
|
||||
issuer, err := client.Get(name, metav1.GetOptions{})
|
||||
if nil != err {
|
||||
return false, fmt.Errorf("error getting ClusterIssuer %v: %v", name, err)
|
||||
@ -143,7 +143,7 @@ func wrapErrorWithClusterIssuerStatusCondition(client clientset.ClusterIssuerInt
|
||||
func WaitForCertificateCondition(client clientset.CertificateInterface, name string, condition v1alpha1.CertificateCondition, timeout time.Duration) error {
|
||||
pollErr := wait.PollImmediate(500*time.Millisecond, timeout,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for Certificate %v condition %#v", name, condition)
|
||||
log.Logf("Waiting for Certificate %v condition %#v", name, condition)
|
||||
certificate, err := client.Get(name, metav1.GetOptions{})
|
||||
if nil != err {
|
||||
return false, fmt.Errorf("error getting Certificate %v: %v", name, err)
|
||||
@ -160,7 +160,7 @@ func WaitForCertificateCondition(client clientset.CertificateInterface, name str
|
||||
func WaitForCertificateEvent(client kubernetes.Interface, cert *v1alpha1.Certificate, reason string, timeout time.Duration) error {
|
||||
return wait.PollImmediate(500*time.Millisecond, timeout,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for Certificate event %v reason %#v", cert.Name, reason)
|
||||
log.Logf("Waiting for Certificate event %v reason %#v", cert.Name, reason)
|
||||
evts, err := client.Core().Events(cert.Namespace).Search(intscheme.Scheme, cert)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("error getting Certificate %v: %v", cert.Name, err)
|
||||
@ -206,7 +206,7 @@ func wrapErrorWithCertificateStatusCondition(client clientset.CertificateInterfa
|
||||
func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secretClient corecs.SecretInterface, name string, timeout time.Duration) error {
|
||||
return wait.PollImmediate(time.Second, timeout,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for Certificate %v to be ready", name)
|
||||
log.Logf("Waiting for Certificate %v to be ready", name)
|
||||
certificate, err := certClient.Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("error getting Certificate %v: %v", name, err)
|
||||
@ -218,7 +218,7 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
if !isReady {
|
||||
return false, nil
|
||||
}
|
||||
glog.Infof("Getting the TLS certificate Secret resource")
|
||||
log.Logf("Getting the TLS certificate Secret resource")
|
||||
secret, err := secretClient.Get(certificate.Spec.SecretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
@ -228,13 +228,13 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
return false, err
|
||||
}
|
||||
if !(len(secret.Data) == 2 || len(secret.Data) == 3) {
|
||||
glog.Infof("Expected 2 keys in certificate secret, but there was %d", len(secret.Data))
|
||||
log.Logf("Expected 2 keys in certificate secret, but there was %d", len(secret.Data))
|
||||
return false, nil
|
||||
}
|
||||
|
||||
keyBytes, ok := secret.Data[v1.TLSPrivateKeyKey]
|
||||
if !ok {
|
||||
glog.Infof("No private key data found for Certificate %q (secret %q)", name, certificate.Spec.SecretName)
|
||||
log.Logf("No private key data found for Certificate %q (secret %q)", name, certificate.Spec.SecretName)
|
||||
return false, nil
|
||||
}
|
||||
key, err := pki.DecodePrivateKeyBytes(keyBytes)
|
||||
@ -248,13 +248,13 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
v1alpha1.RSAKeyAlgorithm:
|
||||
_, ok := key.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
glog.Infof("Expected private key of type RSA, but it was: %T", key)
|
||||
log.Logf("Expected private key of type RSA, but it was: %T", key)
|
||||
return false, nil
|
||||
}
|
||||
case v1alpha1.ECDSAKeyAlgorithm:
|
||||
_, ok := key.(*ecdsa.PrivateKey)
|
||||
if !ok {
|
||||
glog.Infof("Expected private key of type ECDSA, but it was: %T", key)
|
||||
log.Logf("Expected private key of type ECDSA, but it was: %T", key)
|
||||
return false, nil
|
||||
}
|
||||
default:
|
||||
@ -270,7 +270,7 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
|
||||
certBytes, ok := secret.Data[v1.TLSCertKey]
|
||||
if !ok {
|
||||
glog.Infof("No certificate data found for Certificate %q (secret %q)", name, certificate.Spec.SecretName)
|
||||
log.Logf("No certificate data found for Certificate %q (secret %q)", name, certificate.Spec.SecretName)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@ -279,16 +279,16 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
return false, err
|
||||
}
|
||||
if expectedCN != cert.Subject.CommonName || !util.EqualUnsorted(cert.DNSNames, expectedDNSNames) || !(len(cert.Subject.Organization) == 0 || util.EqualUnsorted(cert.Subject.Organization, expectedOrganization)) {
|
||||
glog.Infof("Expected certificate valid for CN %q, O %v, dnsNames %v but got a certificate valid for CN %q, O %v, dnsNames %v", expectedCN, expectedOrganization, expectedDNSNames, cert.Subject.CommonName, cert.Subject.Organization, cert.DNSNames)
|
||||
log.Logf("Expected certificate valid for CN %q, O %v, dnsNames %v but got a certificate valid for CN %q, O %v, dnsNames %v", expectedCN, expectedOrganization, expectedDNSNames, cert.Subject.CommonName, cert.Subject.Organization, cert.DNSNames)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if certificate.Status.NotAfter == nil {
|
||||
glog.Infof("No certificate expiration found for Certificate %q", name)
|
||||
log.Logf("No certificate expiration found for Certificate %q", name)
|
||||
return false, nil
|
||||
}
|
||||
if !cert.NotAfter.Equal(certificate.Status.NotAfter.Time) {
|
||||
glog.Info("Expected certificate expire date to be %v, but got %v", certificate.Status.NotAfter, cert.NotAfter)
|
||||
log.Logf("Expected certificate expiry date to be %v, but got %v", certificate.Status.NotAfter, cert.NotAfter)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@ -310,7 +310,7 @@ func WaitCertificateIssuedValid(certClient clientset.CertificateInterface, secre
|
||||
func WaitForCertificateToExist(client clientset.CertificateInterface, name string, timeout time.Duration) error {
|
||||
return wait.PollImmediate(500*time.Millisecond, timeout,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for Certificate %v to exist", name)
|
||||
log.Logf("Waiting for Certificate %v to exist", name)
|
||||
_, err := client.Get(name, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
return false, nil
|
||||
@ -327,9 +327,9 @@ func WaitForCertificateToExist(client clientset.CertificateInterface, name strin
|
||||
// WaitForCRDToNotExist waits for the CRD with the given name to no
|
||||
// longer exist.
|
||||
func WaitForCRDToNotExist(client apiextcs.CustomResourceDefinitionInterface, name string) error {
|
||||
return wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout,
|
||||
return wait.PollImmediate(500*time.Millisecond, time.Minute,
|
||||
func() (bool, error) {
|
||||
glog.V(5).Infof("Waiting for CRD %v to not exist", name)
|
||||
log.Logf("Waiting for CRD %v to not exist", name)
|
||||
_, err := client.Get(name, metav1.GetOptions{})
|
||||
if nil == err {
|
||||
return false, nil
|
||||
2
test/fixtures/cert-manager-values.yaml
vendored
2
test/fixtures/cert-manager-values.yaml
vendored
@ -13,7 +13,7 @@ resources:
|
||||
memory: 200Mi
|
||||
|
||||
extraArgs:
|
||||
- --v=4
|
||||
- --v=10
|
||||
- --leader-election-lease-duration=10s
|
||||
- --leader-election-renew-deadline=3s
|
||||
- --leader-election-retry-period=2s
|
||||
|
||||
@ -1,29 +1,3 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["util.go"],
|
||||
importpath = "github.com/jetstack/cert-manager/test/util",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/client/clientset/versioned/scheme:go_default_library",
|
||||
"//pkg/client/clientset/versioned/typed/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/util:go_default_library",
|
||||
"//pkg/util/pki:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
|
||||
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user