<commit_before>// +build integrationtest

package integrationtest

import (
	"fmt"
	"testing"
	"time"

	storkv1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1"
	"github.com/portworx/sched-ops/k8s"
	"github.com/portworx/sched-ops/task"
	"github.com/portworx/torpedo/drivers/scheduler"
	"github.com/portworx/torpedo/drivers/scheduler/spec"
	"github.com/sirupsen/logrus"
	"github.com/stretchr/testify/require"
	"k8s.io/apimachinery/pkg/api/errors"
	meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
	testKey               = "<KEY>"
	appKey                = "mysql"
	restoreName           = "mysql-restore"
	backupSyncAnnotation  = "backupsync"
	configMapName         = "secret-config"
	defaultBackupLocation = storkv1.BackupLocationS3
	defaultSecretName     = "s3secret"

	applicationBackupScheduleRetryInterval = 10 * time.Second
	applicationBackupScheduleRetryTimeout  = 3 * time.Minute
	applicationBackupSyncRetryTimeout      = 10 * time.Minute
)

var allConfigMap, defaultConfigMap map[string]string

func TestApplicationBackup(t *testing.T) {
	// Get location types and secret from config maps
	configMap, err := k8s.Instance().GetConfigMap(configMapName, "default")
	require.NoError(t, err, "Failed to get config map  %s", configMap.Name)

	allConfigMap = configMap.Data

	// Default backup location
	defaultConfigMap = getBackupConfigMapForType(allConfigMap, defaultBackupLocation)

	t.Run("applicationBackupRestoreTest", applicationBackupRestoreTest)
	t.Run("preExecRuleTest", applicationBackupRestorePreExecRuleTest)
	t.Run("postExecRuleTest", applicationBackupRestorePostExecRuleTest)
	t.Run("preExecMissingRuleTest", applicationBackupRestorePreExecMissingRuleTest)
	t.Run("postExecMissingRuleTest", applicationBackupRestorePostExecMissingRuleTest)
	t.Run("preExecFailingRuleTest", applicationBackupRestorePreExecFailingRuleTest)
	t.Run("postExecFailingRuleTest", applicationBackupRestorePostExecFailingRuleTest)
	t.Run("labelSelector", applicationBackupLabelSelectorTest)
	t.Run("scheduleTests", applicationBackupScheduleTests)
	t.Run("backupSyncController", applicationBackupSyncControllerTest)
}

func triggerBackupRestoreTest(
	t *testing.T,
	appBackupKey []string,
	additionalAppKeys []string,<commit_msg>Increase timeout for backup test<commit_after>// +build integrationtest

package integrationtest

import (
	"fmt"
	"testing"
	"time"

	storkv1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1"
	"github.com/portworx/sched-ops/k8s"
	"github.com/portworx/sched-ops/task"
	"github.com/portworx/torpedo/drivers/scheduler"
	"github.com/portworx/torpedo/drivers/scheduler/spec"
	"github.com/sirupsen/logrus"
	"github.com/stretchr/testify/require"
	"k8s.io/apimachinery/pkg/api/errors"
	meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
	testKey               = "<KEY>"
	appKey                = "mysql"
	restoreName           = "mysql-restore"
	backupSyncAnnotation  = "backupsync"
	configMapName         = "secret-config"
	defaultBackupLocation = storkv1.BackupLocationS3
	defaultSecretName     = "s3secret"

	applicationBackupScheduleRetryInterval = 10 * time.Second
	applicationBackupScheduleRetryTimeout  = 5 * time.Minute
	applicationBackupSyncRetryTimeout      = 10 * time.Minute
)

var allConfigMap, defaultConfigMap map[string]string

func TestApplicationBackup(t *testing.T) {
	// Get location types and secret from config maps
	configMap, err := k8s.Instance().GetConfigMap(configMapName, "default")
	require.NoError(t, err, "Failed to get config map  %s", configMap.Name)

	allConfigMap = configMap.Data

	// Default backup location
	defaultConfigMap = getBackupConfigMapForType(allConfigMap, defaultBackupLocation)

	t.Run("applicationBackupRestoreTest", applicationBackupRestoreTest)
	t.Run("preExecRuleTest", applicationBackupRestorePreExecRuleTest)
	t.Run("postExecRuleTest", applicationBackupRestorePostExecRuleTest)
	t.Run("preExecMissingRuleTest", applicationBackupRestorePreExecMissingRuleTest)
	t.Run("postExecMissingRuleTest", applicationBackupRestorePostExecMissingRuleTest)
	t.Run("preExecFailingRuleTest", applicationBackupRestorePreExecFailingRuleTest)
	t.Run("postExecFailingRuleTest", applicationBackupRestorePostExecFailingRuleTest)
	t.Run("labelSelector", applicationBackupLabelSelectorTest)
	t.Run("scheduleTests", applicationBackupScheduleTests)
	t.Run("backupSyncController", applicationBackupSyncControllerTest)
}

func triggerBackupRestoreTest(
	t *testing.T,
	appBackupKey []string,
	additionalAppKeys []string,
{'fraction_non_alphanumeric': 0.0999330805264332, 'fraction_numerical': 0.007138077180459514, 'mean_word_length': 6.017214397496088, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1554549', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1473, 'n_words': 219}