Skip to content

Commit

Permalink
[Issue#200] Add persistent storage to make the scale-down e2e test in…
Browse files Browse the repository at this point in the history
…volving transaction recovery

Fixes #200
  • Loading branch information
yersan committed May 13, 2021
1 parent 05c569f commit 283577c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/wildflyserver/transaction_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func setupBeforeScaleDown(t *testing.T, wildflyServer *wildflyv1alpha1.WildFlySe
s := scheme.Scheme
s.AddKnownTypes(wildflyv1alpha1.SchemeGroupVersion, wildflyServer)
// Create a fake client to mock API calls.
cl = fake.NewFakeClient(objs...)
cl = fake.NewFakeClientWithScheme(s, objs...)
// Create a ReconcileWildFlyServer object with the scheme and fake client.
r = &ReconcileWildFlyServer{client: cl, scheme: s, recorder: eventRecorderMock{}, isOpenShift: false}

Expand Down
2 changes: 1 addition & 1 deletion test/framework/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func WildflyScaleDownTest(t *testing.T, applicationTag string) {

name := "example-wildfly-" + unixEpoch()
// create wildflyserver custom resource
wildflyServer := MakeBasicWildFlyServer(namespace, name, "quay.io/wildfly-quickstarts/wildfly-operator-quickstart:"+applicationTag, 2, false)
wildflyServer := MakeBasicWildFlyServerWithStorage(namespace, name, "quay.io/wildfly-quickstarts/wildfly-operator-quickstart:"+applicationTag, 2, false)
// waiting for number of pods matches the desired state
err = CreateAndWaitUntilReady(f, ctx, t, wildflyServer)
if err != nil {
Expand Down
32 changes: 32 additions & 0 deletions test/framework/wildlfyserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
goctx "context"
"fmt"
"io"
"k8s.io/apimachinery/pkg/api/resource"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -48,6 +49,37 @@ func MakeBasicWildFlyServer(ns, name, applicationImage string, size int32, boota
}
}

// MakeBasicWildFlyServerWithStorage creates a basic WildFlyServer resource configured with a persistent storage assuming it will be provisioned
// dynamically by the cluster provider
func MakeBasicWildFlyServerWithStorage(ns, name, applicationImage string, size int32, bootableJar bool) *wildflyv1alpha1.WildFlyServer {
return &wildflyv1alpha1.WildFlyServer{
TypeMeta: metav1.TypeMeta{
Kind: "WildFlyServer",
APIVersion: "wildfly.org/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
},
Spec: wildflyv1alpha1.WildFlyServerSpec{
ApplicationImage: applicationImage,
Replicas: size,
BootableJar: bootableJar,
Storage: &wildflyv1alpha1.StorageSpec{
VolumeClaimTemplate: corev1.PersistentVolumeClaim{
Spec: corev1.PersistentVolumeClaimSpec{
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: resource.MustParse("5Mi"),
},
},
},
},
},
},
}
}

// CreateStandaloneConfigMap creates a ConfigMap for the standalone configuration
func CreateStandaloneConfigMap(f *framework.Framework, ctx *framework.Context, ns string, name string, key string, file []byte) error {
configMap := &corev1.ConfigMap{
Expand Down

0 comments on commit 283577c

Please sign in to comment.