e2e: add S3 test
note: - jenkins config change: S3_TEST_ENABLED -> AWS_TEST_ENABLED
This commit is contained in:
Родитель
1b3ca1737f
Коммит
a3e99199bf
|
@ -35,7 +35,7 @@ export OPERATOR_IMAGE="gcr.io/coreos-k8s-scale-testing/etcd-operator:${GIT_VERSI
|
|||
echo "UNIQUE_BUILD_NAME: ${UNIQUE_BUILD_NAME}"
|
||||
echo "OPERATOR_IMAGE: ${OPERATOR_IMAGE}"
|
||||
echo "TEST_NAMESPACE: ${TEST_NAMESPACE}"
|
||||
echo "S3_TEST_ENABLED: ${S3_TEST_ENABLED}"
|
||||
echo "AWS_TEST_ENABLED: ${AWS_TEST_ENABLED}"
|
||||
|
||||
gcloud docker -a # have docker command access to gcloud
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package e2e
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/coreos/etcd-operator/pkg/spec"
|
||||
)
|
||||
|
||||
func TestS3MajorityDown(t *testing.T) {
|
||||
if os.Getenv("AWS_TEST_ENABLED") != "true" {
|
||||
t.Skip()
|
||||
}
|
||||
testDisasterRecoveryWithStorageType(t, 2, spec.BackupStorageTypeS3)
|
||||
}
|
||||
|
||||
func TestS3AllDown(t *testing.T) {
|
||||
if os.Getenv("AWS_TEST_ENABLED") != "true" {
|
||||
t.Skip()
|
||||
}
|
||||
testDisasterRecoveryWithStorageType(t, 3, spec.BackupStorageTypeS3)
|
||||
}
|
|
@ -19,6 +19,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd-operator/pkg/spec"
|
||||
"github.com/coreos/etcd-operator/test/e2e/framework"
|
||||
)
|
||||
|
||||
|
@ -184,10 +185,14 @@ func TestPauseControl(t *testing.T) {
|
|||
}
|
||||
|
||||
func testDisasterRecovery(t *testing.T, numToKill int) {
|
||||
testDisasterRecoveryWithStorageType(t, numToKill, spec.BackupStorageTypePersistentVolume)
|
||||
}
|
||||
|
||||
func testDisasterRecoveryWithStorageType(t *testing.T, numToKill int, bt spec.BackupStorageType) {
|
||||
f := framework.Global
|
||||
origEtcd := makeEtcdCluster("test-etcd-", 3)
|
||||
origEtcd = etcdClusterWithBackup(origEtcd, makeBackupPolicy(true))
|
||||
testEtcd, err := createEtcdCluster(f, origEtcd)
|
||||
bp := backupPolicyWithStorageType(makeBackupPolicy(true), bt)
|
||||
testEtcd, err := createEtcdCluster(f, etcdClusterWithBackup(origEtcd, bp))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ package framework
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/etcd-operator/pkg/util/k8sutil"
|
||||
|
@ -79,6 +80,10 @@ func (f *Framework) setup(opImage string) error {
|
|||
|
||||
func (f *Framework) setupEtcdOperator(opImage string) error {
|
||||
// TODO: unify this and the yaml file in example/
|
||||
cmd := "/usr/local/bin/etcd-operator --analytics=false"
|
||||
if os.Getenv("AWS_TEST_ENABLED") == "true" {
|
||||
cmd += " --backup-aws-secret=aws --backup-aws-config=aws --backup-s3-bucket=jenkins-etcd-operator"
|
||||
}
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "etcd-operator",
|
||||
|
@ -90,8 +95,7 @@ func (f *Framework) setupEtcdOperator(opImage string) error {
|
|||
Name: "etcd-operator",
|
||||
Image: opImage,
|
||||
Command: []string{
|
||||
"/bin/sh", "-c",
|
||||
"/usr/local/bin/etcd-operator --analytics=false",
|
||||
"/bin/sh", "-c", cmd,
|
||||
},
|
||||
Env: []api.EnvVar{
|
||||
{
|
||||
|
|
|
@ -146,6 +146,11 @@ func makeBackupPolicy(cleanup bool) *spec.BackupPolicy {
|
|||
}
|
||||
}
|
||||
|
||||
func backupPolicyWithStorageType(bp *spec.BackupPolicy, bt spec.BackupStorageType) *spec.BackupPolicy {
|
||||
bp.StorageType = bt
|
||||
return bp
|
||||
}
|
||||
|
||||
func etcdClusterWithBackup(ec *spec.EtcdCluster, backupPolicy *spec.BackupPolicy) *spec.EtcdCluster {
|
||||
ec.Spec.Backup = backupPolicy
|
||||
return ec
|
||||
|
|
Загрузка…
Ссылка в новой задаче