зеркало из https://github.com/Azure/orkestra.git
Initial Create Testing (#223)
* Add basic create test case * Fix create testing
This commit is contained in:
Родитель
6f82284ff8
Коммит
b52a2b1917
|
@ -22,8 +22,6 @@ spec:
|
|||
# name: <secret-name>
|
||||
# namespace: <secret-namespace>
|
||||
release:
|
||||
upgrade:
|
||||
force: true
|
||||
targetNamespace: ambassador
|
||||
values:
|
||||
service:
|
||||
|
@ -45,8 +43,6 @@ spec:
|
|||
- name: details
|
||||
dependencies: []
|
||||
release:
|
||||
upgrade:
|
||||
force: true
|
||||
targetNamespace: bookinfo
|
||||
values:
|
||||
productpage:
|
||||
|
|
|
@ -2,6 +2,15 @@ package controllers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Azure/Orkestra/api/v1alpha1"
|
||||
"github.com/Azure/Orkestra/pkg/meta"
|
||||
v1alpha12 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
|
||||
fluxhelmv2beta1 "github.com/fluxcd/helm-controller/api/v2beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
"time"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -9,29 +18,88 @@ import (
|
|||
)
|
||||
|
||||
var _ = Describe("ApplicationGroup Controller", func() {
|
||||
BeforeEach(func() {
|
||||
// Add any setup steps that needs to be executed before each test
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
// Add any teardown steps that needs to be executed after each test
|
||||
})
|
||||
Context("ApplicationGroup", func() {
|
||||
var (
|
||||
namespace *corev1.Namespace
|
||||
ctx context.Context
|
||||
)
|
||||
|
||||
Context("Submit Bookinfo ApplicationGroup", func() {
|
||||
It("Should create successfully", func() {
|
||||
// applicationGroupKey := types.NamespacedName{
|
||||
// Name: "bookinfo",
|
||||
// }
|
||||
const (
|
||||
DefaultNamesapce = "orkestra"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
// TODO: Namespace will be added once we have the namespace based support for ApplicationGroup
|
||||
namespace = &corev1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "appgroup-test" + randStringRunes(5),
|
||||
},
|
||||
}
|
||||
ctx = context.Background()
|
||||
_ = k8sClient.Create(ctx, namespace)
|
||||
//Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
err := k8sClient.Delete(ctx, namespace)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("Should create Bookinfo spec successfully", func() {
|
||||
ctx := context.Background()
|
||||
applicationGroup := bookinfo()
|
||||
applicationGroup.Namespace = DefaultNamesapce
|
||||
key := client.ObjectKeyFromObject(applicationGroup)
|
||||
|
||||
By("Applying the bookinfo object to the cluster")
|
||||
Expect(k8sClient.Create(context.Background(), applicationGroup)).Should(Succeed())
|
||||
time.Sleep(time.Second * 5)
|
||||
err := k8sClient.Create(ctx, applicationGroup)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Defer the cleanup so that we delete the appGroup after creation
|
||||
defer func() {
|
||||
Expect(k8sClient.Delete(context.Background(), applicationGroup)).Should(Succeed())
|
||||
time.Sleep(time.Second * 5)
|
||||
By("Deleting the bookinfo object from the cluster")
|
||||
patch := client.MergeFrom(applicationGroup.DeepCopy())
|
||||
controllerutil.RemoveFinalizer(applicationGroup, "application-group-finalizer")
|
||||
_ = k8sClient.Patch(ctx, applicationGroup, patch)
|
||||
_ = k8sClient.Delete(ctx, applicationGroup)
|
||||
}()
|
||||
|
||||
helmReleaseList := &fluxhelmv2beta1.HelmReleaseList{}
|
||||
err = k8sClient.List(ctx, helmReleaseList)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
oldHelmReleaseCount := len(helmReleaseList.Items)
|
||||
|
||||
By("Making sure that the workflow goes into a running state")
|
||||
Eventually(func() bool {
|
||||
workflow := &v1alpha12.Workflow{}
|
||||
workflowKey := types.NamespacedName{Name: applicationGroup.Name, Namespace: applicationGroup.Namespace}
|
||||
_ = k8sClient.Get(ctx, workflowKey, workflow)
|
||||
return workflow.Status.Phase == v1alpha12.NodeRunning
|
||||
}, time.Minute, time.Second).Should(BeTrue())
|
||||
|
||||
By("Waiting for the bookinfo object to reach a succeeded reason")
|
||||
Eventually(func() bool {
|
||||
applicationGroup = &v1alpha1.ApplicationGroup{}
|
||||
if err := k8sClient.Get(ctx, key, applicationGroup); err != nil {
|
||||
return false
|
||||
}
|
||||
return applicationGroup.GetReadyCondition() == meta.SucceededReason
|
||||
}, time.Minute*4, time.Second).Should(BeTrue())
|
||||
|
||||
By("checking that the all the HelmReleases have come up and are in a ready state")
|
||||
err = k8sClient.List(ctx, helmReleaseList)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(len(helmReleaseList.Items)).To(Equal(oldHelmReleaseCount + 6))
|
||||
allReady := true
|
||||
for _, release := range helmReleaseList.Items {
|
||||
if condition := meta.GetResourceCondition(&release, meta.ReadyCondition); condition.Reason == meta.SucceededReason {
|
||||
allReady = false
|
||||
}
|
||||
}
|
||||
Expect(allReady).To(BeTrue())
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
|
||||
orkestrav1alpha1 "github.com/Azure/Orkestra/api/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
@ -18,7 +19,6 @@ func bookinfo() *orkestrav1alpha1.ApplicationGroup {
|
|||
Name: "bookinfo",
|
||||
},
|
||||
}
|
||||
|
||||
yamlFile, err := ioutil.ReadFile(bookinfoExampleFilePath)
|
||||
if err != nil {
|
||||
log.Fatalf("yamlFile.Get err #%v", err)
|
||||
|
@ -32,3 +32,13 @@ func bookinfo() *orkestrav1alpha1.ApplicationGroup {
|
|||
|
||||
return g
|
||||
}
|
||||
|
||||
var letterRunes = []rune("abcdefghijklmnopqrstuvwxyz1234567890")
|
||||
|
||||
func randStringRunes(n int) string {
|
||||
b := make([]rune, n)
|
||||
for i := range b {
|
||||
b[i] = letterRunes[rand.Intn(len(letterRunes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ spec:
|
|||
# namespace: <secret-namespace>
|
||||
release:
|
||||
timeout: 10m
|
||||
upgrade:
|
||||
force: true
|
||||
targetNamespace: ambassador
|
||||
values:
|
||||
service:
|
||||
|
@ -45,8 +43,6 @@ spec:
|
|||
- name: details
|
||||
dependencies: []
|
||||
release:
|
||||
upgrade:
|
||||
force: true
|
||||
targetNamespace: bookinfo
|
||||
values:
|
||||
productpage:
|
||||
|
|
7
go.mod
7
go.mod
|
@ -5,8 +5,9 @@ go 1.15
|
|||
require (
|
||||
github.com/argoproj/argo v2.5.2+incompatible
|
||||
github.com/chartmuseum/helm-push v0.9.0
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fluxcd/helm-controller/api v0.9.0
|
||||
github.com/fluxcd/pkg/apis/meta v0.9.0
|
||||
github.com/fluxcd/source-controller/api v0.12.2
|
||||
github.com/go-logr/logr v0.4.0
|
||||
github.com/go-openapi/spec v0.19.5 // indirect
|
||||
github.com/gofrs/flock v0.8.0
|
||||
|
@ -15,8 +16,8 @@ require (
|
|||
github.com/jinzhu/copier v0.3.0
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
|
||||
github.com/onsi/ginkgo v1.16.1 // indirect
|
||||
github.com/onsi/gomega v1.11.0 // indirect
|
||||
github.com/onsi/ginkgo v1.16.1
|
||||
github.com/onsi/gomega v1.11.0
|
||||
go.opencensus.io v0.22.5 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
|
||||
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
|
||||
|
|
12
go.sum
12
go.sum
|
@ -255,10 +255,13 @@ github.com/fluxcd/helm-controller/api v0.9.0 h1:L60KmCblTQo3UimgCzVQGe330tC+b15C
|
|||
github.com/fluxcd/helm-controller/api v0.9.0/go.mod h1:HIWSF3n1QU3hdqjQMFizFUZVr1uV+abmlGAEpB7vB9A=
|
||||
github.com/fluxcd/pkg/apis/kustomize v0.0.1 h1:TkA80R0GopRY27VJqzKyS6ifiKIAfwBd7OHXtV3t2CI=
|
||||
github.com/fluxcd/pkg/apis/kustomize v0.0.1/go.mod h1:JAFPfnRmcrAoG1gNiA8kmEXsnOBuDyZ/F5X4DAQcVV0=
|
||||
github.com/fluxcd/pkg/apis/meta v0.8.0 h1:wqWpUsxhKHB1ZztcvOz+vnyhdKW9cWmjFp8Vci/XOdk=
|
||||
github.com/fluxcd/pkg/apis/meta v0.8.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po=
|
||||
github.com/fluxcd/pkg/apis/meta v0.9.0 h1:rxW69p+VmJCKXXkaRYnovRBFlKjd+MJQfm2RrB0B4j8=
|
||||
github.com/fluxcd/pkg/apis/meta v0.9.0/go.mod h1:yHuY8kyGHYz22I0jQzqMMGCcHViuzC/WPdo9Gisk8Po=
|
||||
github.com/fluxcd/pkg/runtime v0.10.1 h1:NV0pe6lFzodKBIz0dT3xkoR0wJnTCicXwM/v/d5T0+Y=
|
||||
github.com/fluxcd/pkg/runtime v0.10.1/go.mod h1:JD0eZIn5xkTeHHQUWXSqJPIh/ecO0d0qrUKbSVHnpnw=
|
||||
github.com/fluxcd/source-controller/api v0.12.2 h1:8n9+poUv/6bAEgteTxKV591aKzqRIv391VS8uD1imzo=
|
||||
github.com/fluxcd/source-controller/api v0.12.2/go.mod h1:+EPyhxC7Y+hUnq7EwAkkLtfbwCxJxF5yfmiyzDk43KY=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
|
@ -342,7 +345,6 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
|||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/envy v1.7.1 h1:OQl5ys5MBea7OGCdvPbBJWRgnhC/fGona6QKfvFeau8=
|
||||
|
@ -621,7 +623,6 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
|
|||
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
|
@ -638,8 +639,6 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
|
|||
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
|
||||
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/ginkgo v1.16.1 h1:foqVmeWDD6yYpK+Yz3fHyNIxFYNxswxqNFjSKe+vI54=
|
||||
github.com/onsi/ginkgo v1.16.1/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
|
||||
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
|
@ -647,7 +646,6 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
|
|||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs=
|
||||
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug=
|
||||
github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg=
|
||||
|
@ -964,7 +962,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
|
|||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
|
@ -1117,7 +1114,6 @@ golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roY
|
|||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d h1:W07d4xkoAUSNOkOzdzXCdFGxT7o2rW4q8M34tB2i//k=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
|
|
Загрузка…
Ссылка в новой задаче