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.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Jul 16, 2023
1 parent 2665807 commit 465bc51
Show file tree
Hide file tree
Showing 16 changed files with 222 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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.

- `subscription`: Base busybox subscription. To create an actual
subscription crate an overlay and kustomize the namespace git
github-path annotation.

## 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
```

2. Install the subscription

To install the `rbd` subscription and application:

```
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`.
33 changes: 33 additions & 0 deletions test/apps/busybox/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
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 echo $(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
4 changes: 4 additions & 0 deletions test/apps/busybox/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
resources:
- pvc.yaml
- deploy.yaml
14 changes: 14 additions & 0 deletions test/apps/busybox/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: busybox-pvc
labels:
appname: busybox
spec:
accessModes:
- ReadWriteOnce
storageClassName: storage-class-name
resources:
requests:
storage: 5Gi
9 changes: 9 additions & 0 deletions test/apps/channel/channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: apps.open-cluster-management.io/v1
kind: Channel
metadata:
name: ramen-gitops
namespace: ramen-samples
spec:
type: GitHub
pathname: https://github.com/RamenDR/ramen.git
3 changes: 3 additions & 0 deletions test/apps/channel/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- channel.yaml
- namespace.yaml
5 changes: 5 additions & 0 deletions test/apps/channel/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: ramen-samples
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
17 changes: 17 additions & 0 deletions test/apps/subscription/drpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
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
5 changes: 5 additions & 0 deletions test/apps/subscription/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- namespace.yaml
- placementrule.yaml
- subscription.yaml
- drpc.yaml
5 changes: 5 additions & 0 deletions test/apps/subscription/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: busybox-sample
13 changes: 13 additions & 0 deletions test/apps/subscription/placementrule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
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
16 changes: 16 additions & 0 deletions test/apps/subscription/subscription.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
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-samples/ramen-gitops
placement:
placementRef:
kind: PlacementRule
name: busybox-placement

0 comments on commit 465bc51

Please sign in to comment.