Skip to content

Commit

Permalink
Add test applications
Browse files Browse the repository at this point in the history
Add tests application based on ocm-ramen-samples for using in drenv
tests.

We 2 variants:

- `rbd`: for testing replication using RBD mirroring
- `hostpath`: for testing replication using minikube `csi-hostpath-sc`
  via volsync.

The application are identical except the pvc storage class and
namespace. We can add another variant for CephFS once we add it to to
test environment.

Differences compared to ocm-ramen-samples:

- Different directory layout - every app has a subscription and
  application directory. Both use kustomization based on a base
  application or subscription.
- The channel is separated from the applications, since we have need
  only one channel pointing to the ramen repo.
- The deployment uses security context so the app runs as unprivileged
  user.
- The apps are part of ramen repo, so it is easier to maintain, an we
  don't need to worry about affecting users or QE when changing the
  applications.
- Fix yamllint errors
- Add SPDX headers

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Jul 16, 2023
1 parent 2665807 commit 4c97203
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Ramen test applications

This directory contains test applications for testing disaster recovery
flows using the drenv environment.

The applications are kustomized for minikube based clusters. To test on
OpenShift clusters, use the
[RamenDR ocm-ramen-samples repository](https://github.com/RamenDR/ocm-ramen-samples).

## Channel

Channel pointing to ramen github repo. Must be installed to use these
applications.

## Bases

- `busybox`: Base busybox application. To create an actual application
create an overlay and kustomize namespace and the pvc
storageClassName. See `*/busybox/kustomization.yaml` for example.

- `subscription`: Base busybox subscription. To create an actual
subscription create an overlay and kustomize the namespace and
github-path annotation. See `*/subscription/kustomization.yaml` for
example.

## Overlays

- `rbd`: busybox and subscription overlays for testing replication with
RBD mirroring.

- `hostpath`: busybox and subscription overlays for testing replication
using `csi-hostpath-sc` storage class via `volsync`.

## Deployment

1. Install the channel

```
kubectl apply -k channel
```

This install a `ramen-gitops` channel in the `ramen-test` namespace,
pointing the ramen repo on github.

1. Install the subscriptions

```
kubectl apply -k rbd/subscription
```

This installs the `busybox-sub` subscription in in the `busybox-rbd`
namespace on the 'hub' cluster, and the `busybox` application in the
`busybox-rbd` namespace in cluster `dr1`.

To install the `hostpath` subscription replace `rbd` with `hostpath`.
The subscription and applications are installed in the
`busybox-hostpath` namespace.
46 changes: 46 additions & 0 deletions test/apps/busybox/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
appname: busybox
name: busybox
spec:
replicas: 1
selector:
matchLabels:
appname: busybox
template:
metadata:
labels:
appname: busybox
spec:
containers:
- image: docker.io/library/busybox:stable
imagePullPolicy: IfNotPresent
name: busybox
command:
- sh
- -c
- |
trap exit TERM
while true; do
date | tee -a /mnt/test/outfile
sync
sleep 10 &
wait
done
volumeMounts:
- name: mypvc
mountPath: /mnt/test
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: busybox-pvc
securityContext:
runAsUser: 10000
runAsGroup: 10000
fsGroup: 10000
7 changes: 7 additions & 0 deletions test/apps/busybox/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
resources:
- pvc.yaml
- deploy.yaml
17 changes: 17 additions & 0 deletions test/apps/busybox/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: busybox-pvc
labels:
appname: busybox
spec:
accessModes:
- ReadWriteOnce
storageClassName: storage-class-name
resources:
requests:
storage: 1Gi
12 changes: 12 additions & 0 deletions test/apps/channel/channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
name: ramen-gitops
namespace: ramen-test
spec:
type: GitHub
pathname: https://github.com/RamenDR/ramen.git
7 changes: 7 additions & 0 deletions test/apps/channel/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
resources:
- channel.yaml
- namespace.yaml
8 changes: 8 additions & 0 deletions test/apps/channel/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Namespace
metadata:
name: ramen-test
12 changes: 12 additions & 0 deletions test/apps/hostpath/busybox/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
resources:
- ../../busybox
namespace: busybox-hostpath
patches:
- target:
kind: PersistentVolumeClaim
name: busybox-pvc
patch: |-
- op: replace
path: /spec/storageClassName
value: csi-hostpath-sc
12 changes: 12 additions & 0 deletions test/apps/hostpath/subscription/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
resources:
- ../../subscription
namespace: busybox-hostpath
patches:
- target:
kind: Subscription
name: busybox-sub
patch: |-
- op: replace
path: /metadata/annotations/apps.open-cluster-management.io~1github-path
value: test/apps/hostpath/busybox
12 changes: 12 additions & 0 deletions test/apps/rbd/busybox/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
resources:
- ../../busybox
namespace: busybox-rbd
patches:
- target:
kind: PersistentVolumeClaim
name: busybox-pvc
patch: |-
- op: replace
path: /spec/storageClassName
value: rook-ceph-block
12 changes: 12 additions & 0 deletions test/apps/rbd/subscription/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
resources:
- ../../subscription
namespace: busybox-rbd
patches:
- target:
kind: Subscription
name: busybox-sub
patch: |-
- op: replace
path: /metadata/annotations/apps.open-cluster-management.io~1github-path
value: test/apps/rbd/busybox
20 changes: 20 additions & 0 deletions test/apps/subscription/drpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: ramendr.openshift.io/v1alpha1
kind: DRPlacementControl
metadata:
name: busybox-drpc
labels:
app: busybox-sample
spec:
preferredCluster: dr1
drPolicyRef:
name: dr-policy
placementRef:
kind: PlacementRule
name: busybox-placement
pvcSelector:
matchLabels:
appname: busybox
9 changes: 9 additions & 0 deletions test/apps/subscription/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
resources:
- namespace.yaml
- placementrule.yaml
- subscription.yaml
- drpc.yaml
8 changes: 8 additions & 0 deletions test/apps/subscription/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: v1
kind: Namespace
metadata:
name: busybox-sample
16 changes: 16 additions & 0 deletions test/apps/subscription/placementrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps.open-cluster-management.io/v1
kind: PlacementRule
metadata:
name: busybox-placement
labels:
app: busybox-sample
spec:
clusterConditions:
- type: ManagedClusterConditionAvailable
status: "True"
clusterReplicas: 1
schedulerName: ramen
19 changes: 19 additions & 0 deletions test/apps/subscription/subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

---
apiVersion: apps.open-cluster-management.io/v1
kind: Subscription
metadata:
annotations:
apps.open-cluster-management.io/github-branch: main
apps.open-cluster-management.io/github-path: github-path
labels:
app: busybox-sample
name: busybox-sub
spec:
channel: ramen-test/ramen-gitops
placement:
placementRef:
kind: PlacementRule
name: busybox-placement

0 comments on commit 4c97203

Please sign in to comment.