splitting tests into groups
parent
b0cdda756f
commit
7075a20c02
|
@ -12,6 +12,8 @@ import (
|
||||||
apps_v1 "k8s.io/api/apps/v1"
|
apps_v1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dockerHub0150Webhook = `{
|
var dockerHub0150Webhook = `{
|
||||||
|
@ -38,21 +40,37 @@ var dockerHub0150Webhook = `{
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
|
||||||
func TestSemverUpdate(t *testing.T) {
|
func TestWebhooksSemverUpdate(t *testing.T) {
|
||||||
|
|
||||||
// stop := make(chan struct{})
|
// stop := make(chan struct{})
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
// defer close(ctx)
|
// defer close(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
go startKeel(ctx)
|
// go startKeel(ctx)
|
||||||
|
keel := &KeelCmd{}
|
||||||
|
go func() {
|
||||||
|
err := keel.Start(ctx)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
}).Error("failed to start Keel process")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
err := keel.Stop()
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
}).Error("failed to stop Keel process")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
_, kcs := getKubernetesClient()
|
_, kcs := getKubernetesClient()
|
||||||
|
|
||||||
t.Run("UpdateThroughDockerHubWebhook", func(t *testing.T) {
|
t.Run("UpdateThroughDockerHubWebhook", func(t *testing.T) {
|
||||||
|
|
||||||
// t.Skip()
|
|
||||||
|
|
||||||
testNamespace := createNamespaceForTest()
|
testNamespace := createNamespaceForTest()
|
||||||
defer deleteTestNamespace(testNamespace)
|
defer deleteTestNamespace(testNamespace)
|
||||||
|
|
||||||
|
@ -122,6 +140,36 @@ func TestSemverUpdate(t *testing.T) {
|
||||||
t.Errorf("update failed: %s", err)
|
t.Errorf("update failed: %s", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPollingSemverUpdate(t *testing.T) {
|
||||||
|
|
||||||
|
// stop := make(chan struct{})
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
// defer close(ctx)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
// go startKeel(ctx)
|
||||||
|
keel := &KeelCmd{}
|
||||||
|
go func() {
|
||||||
|
err := keel.Start(ctx)
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
}).Error("failed to start Keel process")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
err := keel.Stop()
|
||||||
|
if err != nil {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"error": err,
|
||||||
|
}).Error("failed to stop Keel process")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
_, kcs := getKubernetesClient()
|
||||||
|
|
||||||
t.Run("UpdateThroughDockerHubPollingA", func(t *testing.T) {
|
t.Run("UpdateThroughDockerHubPollingA", func(t *testing.T) {
|
||||||
// UpdateThroughDockerHubPollingA tests a polling trigger when we have a higher version
|
// UpdateThroughDockerHubPollingA tests a polling trigger when we have a higher version
|
||||||
|
@ -140,7 +188,9 @@ func TestSemverUpdate(t *testing.T) {
|
||||||
types.KeelPolicyLabel: "major",
|
types.KeelPolicyLabel: "major",
|
||||||
types.KeelTriggerLabel: "poll",
|
types.KeelTriggerLabel: "poll",
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{},
|
Annotations: map[string]string{
|
||||||
|
types.KeelPollScheduleAnnotation: "@every 2s",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
apps_v1.DeploymentSpec{
|
apps_v1.DeploymentSpec{
|
||||||
Selector: &meta_v1.LabelSelector{
|
Selector: &meta_v1.LabelSelector{
|
||||||
|
@ -192,13 +242,15 @@ func TestSemverUpdate(t *testing.T) {
|
||||||
dep := &apps_v1.Deployment{
|
dep := &apps_v1.Deployment{
|
||||||
meta_v1.TypeMeta{},
|
meta_v1.TypeMeta{},
|
||||||
meta_v1.ObjectMeta{
|
meta_v1.ObjectMeta{
|
||||||
Name: "deployment-1",
|
Name: "deployment-2",
|
||||||
Namespace: testNamespace,
|
Namespace: testNamespace,
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
types.KeelPolicyLabel: "major",
|
types.KeelPolicyLabel: "major",
|
||||||
types.KeelTriggerLabel: "poll",
|
types.KeelTriggerLabel: "poll",
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{},
|
Annotations: map[string]string{
|
||||||
|
types.KeelPollScheduleAnnotation: "@every 2s",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
apps_v1.DeploymentSpec{
|
apps_v1.DeploymentSpec{
|
||||||
Selector: &meta_v1.LabelSelector{
|
Selector: &meta_v1.LabelSelector{
|
||||||
|
|
|
@ -72,10 +72,13 @@ func deleteTestNamespace(namespace string) error {
|
||||||
return clientset.CoreV1().Namespaces().Delete(namespace, &deleteOptions)
|
return clientset.CoreV1().Namespaces().Delete(namespace, &deleteOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func startKeel(ctx context.Context) error {
|
type KeelCmd struct {
|
||||||
|
cmd *exec.Cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kc *KeelCmd) Start(ctx context.Context) error {
|
||||||
|
|
||||||
log.Info("keel started")
|
log.Info("keel started")
|
||||||
defer log.Info("keel stopped")
|
|
||||||
|
|
||||||
cmd := "keel"
|
cmd := "keel"
|
||||||
args := []string{"--no-incluster", "--kubeconfig", getKubeConfig()}
|
args := []string{"--no-incluster", "--kubeconfig", getKubeConfig()}
|
||||||
|
@ -83,17 +86,16 @@ func startKeel(ctx context.Context) error {
|
||||||
c.Stdout = os.Stdout
|
c.Stdout = os.Stdout
|
||||||
c.Stderr = os.Stderr
|
c.Stderr = os.Stderr
|
||||||
|
|
||||||
go func() {
|
kc.cmd = c
|
||||||
<-ctx.Done()
|
|
||||||
err := c.Process.Kill()
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("failed to kill keel process: %s", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
return c.Run()
|
return c.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (kc *KeelCmd) Stop() error {
|
||||||
|
defer log.Info("keel stopped")
|
||||||
|
return kc.cmd.Process.Kill()
|
||||||
|
}
|
||||||
|
|
||||||
func waitFor(ctx context.Context, kcs *kubernetes.Clientset, namespace, name string, desired string) error {
|
func waitFor(ctx context.Context, kcs *kubernetes.Clientset, namespace, name string, desired string) error {
|
||||||
last := ""
|
last := ""
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in New Issue