Skip to content

Commit

Permalink
emojivoto test
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli committed Aug 18, 2023
1 parent 319c7c8 commit cd2dfb1
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 3 deletions.
65 changes: 64 additions & 1 deletion test/e2e/cruise/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,70 @@ var _ = Describe("Liqo E2E", func() {
}, timeout, interval).Should(BeTrue())

By("Verify Online Boutique Connectivity")
err = microservices.CheckApplicationIsWorking(GinkgoT(), options)
err = microservices.CheckApplicationIsWorking(GinkgoT(), options, "frontend-external")
Expect(err).ShouldNot(HaveOccurred())

// cleanup the namespace
Expect(testContext.Clusters[0].NativeClient.CoreV1().Namespaces().Delete(ctx, namespace, metav1.DeleteOptions{})).To(Succeed())
}, generateTableEntries()...)...)
})

Context("E2E Testing with Emojivoto", func() {

var (
manifestBasePath = "./test/e2e/manifests/emojivoto/"
)

type manifest struct {
fileName string
minNCluster int
}

var (
manifests = []manifest{
{
fileName: "manifest.yaml",
minNCluster: 2,
},
}

generateTableEntries = func() []TableEntry {
var entries []TableEntry
for i := range manifests {
if testContext.ClustersNumber < manifests[i].minNCluster {
continue
}

// check if the basePath dir exists
if _, err := os.Stat(manifestBasePath); os.IsNotExist(err) {
// trim ./ prefix
manifestBasePath = strings.TrimPrefix(manifestBasePath, "./")
// append new prefix
manifestBasePath = fmt.Sprintf("/runner/_work/liqops/liqops/liqo/%v", manifestBasePath)
}

entries = append(entries, Entry(
fmt.Sprintf("Deploying the Emojivoto app with manifest %v", manifests[i].fileName),
fmt.Sprintf("%v%v", manifestBasePath, manifests[i].fileName),
fmt.Sprintf("%v-%v", microservices.TestNamespaceName, i),
))
}
return entries
}
)

DescribeTable("Testing Emojivoto", util.DescribeTableArgs(func(manifest, namespace string) {
By("Deploying the Emojivoto app")
options := k8s.NewKubectlOptions("", testContext.Clusters[0].KubeconfigPath, namespace)
defer GinkgoRecover()
err := microservices.DeployApp(GinkgoT(), testContext.Clusters[0].KubeconfigPath, manifest, namespace)
Expect(err).ShouldNot(HaveOccurred())

By("Waiting until each service of the application has ready endpoints")
microservices.WaitDemoApp(GinkgoT(), options)

By("Verify Emojivoto Connectivity")
err = microservices.CheckApplicationIsWorking(GinkgoT(), options, "web-svc")
Expect(err).ShouldNot(HaveOccurred())

// cleanup the namespace
Expand Down
257 changes: 257 additions & 0 deletions test/e2e/manifests/emojivoto/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: emoji
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: voting
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: web
---
apiVersion: v1
kind: Service
metadata:
name: emoji-svc
spec:
ports:
- name: grpc
port: 8080
targetPort: 8080
- name: prom
port: 8801
targetPort: 8801
selector:
app: emoji-svc
---
apiVersion: v1
kind: Service
metadata:
name: voting-svc
spec:
ports:
- name: grpc
port: 8080
targetPort: 8080
- name: prom
port: 8801
targetPort: 8801
selector:
app: voting-svc
---
apiVersion: v1
kind: Service
metadata:
name: web-svc
spec:
ports:
- name: http
port: 80
targetPort: 8080
selector:
app: web-svc
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: emoji
app.kubernetes.io/part-of: emojivoto
app.kubernetes.io/version: v11
name: emoji
spec:
replicas: 1
selector:
matchLabels:
app: emoji-svc
version: v11
template:
metadata:
labels:
app: emoji-svc
version: v11
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: liqo.io/type
operator: NotIn
values:
- virtual-node
containers:
- env:
- name: GRPC_PORT
value: "8080"
- name: PROM_PORT
value: "8801"
image: docker.l5d.io/buoyantio/emojivoto-emoji-svc:v11
name: emoji-svc
ports:
- containerPort: 8080
name: grpc
- containerPort: 8801
name: prom
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
serviceAccountName: emoji
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: vote-bot
app.kubernetes.io/part-of: emojivoto
app.kubernetes.io/version: v11
name: vote-bot
spec:
replicas: 1
selector:
matchLabels:
app: vote-bot
version: v11
template:
metadata:
labels:
app: vote-bot
version: v11
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: liqo.io/type
operator: In
values:
- virtual-node
containers:
- command:
- emojivoto-vote-bot
env:
- name: WEB_HOST
value: web-svc:80
image: docker.l5d.io/buoyantio/emojivoto-web:v11
name: vote-bot
resources:
requests:
cpu: 10m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: voting
app.kubernetes.io/part-of: emojivoto
app.kubernetes.io/version: v11
name: voting
spec:
replicas: 1
selector:
matchLabels:
app: voting-svc
version: v11
template:
metadata:
labels:
app: voting-svc
version: v11
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: liqo.io/type
operator: NotIn
values:
- virtual-node
containers:
- env:
- name: GRPC_PORT
value: "8080"
- name: PROM_PORT
value: "8801"
image: docker.l5d.io/buoyantio/emojivoto-voting-svc:v11
name: voting-svc
ports:
- containerPort: 8080
name: grpc
- containerPort: 8801
name: prom
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
serviceAccountName: voting
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: web
app.kubernetes.io/part-of: emojivoto
app.kubernetes.io/version: v11
name: web
spec:
replicas: 1
selector:
matchLabels:
app: web-svc
version: v11
template:
metadata:
labels:
app: web-svc
version: v11
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: liqo.io/type
operator: In
values:
- virtual-node
containers:
- env:
- name: WEB_PORT
value: "8080"
- name: EMOJISVC_HOST
value: emoji-svc:8080
- name: VOTINGSVC_HOST
value: voting-svc:8080
- name: INDEX_BUNDLE
value: dist/index_bundle.js
image: docker.l5d.io/buoyantio/emojivoto-web:v11
name: web-svc
ports:
- containerPort: 8080
name: http
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 100m
memory: 100Mi
serviceAccountName: web
4 changes: 2 additions & 2 deletions test/e2e/testutils/microservices/deploy_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func WaitDemoApp(t ginkgo.GinkgoTInterface, options *k8s.KubectlOptions) {
}

// CheckApplicationIsWorking performs HTTP requests to the micro-service application to assess its functionality and availability.
func CheckApplicationIsWorking(t ginkgo.GinkgoTInterface, options *k8s.KubectlOptions) error {
service := k8s.GetService(t, options, "frontend-external")
func CheckApplicationIsWorking(t ginkgo.GinkgoTInterface, options *k8s.KubectlOptions, serviceName string) error {
service := k8s.GetService(t, options, serviceName)
if len(service.Spec.Ports) == 0 {
return fmt.Errorf("frontend service not found")
}
Expand Down

0 comments on commit cd2dfb1

Please sign in to comment.