-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues in e2e test #442
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6d5c9f2
Fix issues in e2e test
kevinliu24 00b0170
Increase timeout for cluster wait
kevinliu24 1488b9c
Remove unneeded comments
kevinliu24 2379e22
Remove unneeded blank line
kevinliu24 0624d6d
Merge remote-tracking branch 'origin/master' into fix_e2e_tests
kevinliu24 ff4b689
Merge remote-tracking branch 'origin/master' into fix_e2e_tests
kevinliu24 86cd3cb
Merge remote-tracking branch 'origin/master' into fix_e2e_tests
kevinliu24 448718d
Add nebula backup e2e tests
kevinliu24 6e36261
Merge remote-tracking branch 'origin/master' into fix_e2e_tests
kevinliu24 c3f1899
Fix pull request according to review and add cron backup tests
kevinliu24 47ca53f
add env values to github action e2e and delete created nr after each …
kevinliu24 7a4c104
Fix review comments on nebula backup and restore tests.
kevinliu24 662dd71
leave annotation.AnnLastReplicas alone
kevinliu24 138352d
Fix cronbackup and env issue
kevinliu24 f4981b0
Merge remote-tracking branch 'origin/master' into fix_e2e_tests
kevinliu24 b6aed4b
Fix timeout
kevinliu24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,9 +57,16 @@ jobs: | |
export E2E_DOCKER_CONFIG_JSON_SECRET=`cat ~/.docker/config.json| base64 -w 0` | ||
make e2e E2EARGS="-v=5 -skip-features 'pv expansion|custom config for dynamic|tools for exporter'" | ||
env: | ||
E2E_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
E2E_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
E2E_BR_IMAGE: reg.vesoft-inc.com/cloud-dev/br-ent | ||
E2E_BR_VERSION: v3.7.0 | ||
E2E_GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | ||
E2E_OPERATOR_IMAGE: reg.vesoft-inc.com/ci/nebula-operator:ci-e2e | ||
E2E_OPERATOR_INSTALL: "true" | ||
E2E_NC_VERSION: v3.6.0 | ||
E2E_NC_VERSION: v3.7.0 | ||
E2E_NC_AGENT_IMAGE: reg.vesoft-inc.com/cloud-dev/nebula-agent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why put it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MegaByte875 to move them into the CI folder |
||
E2E_NC_AGENT_VERSION: v3.6.0 | ||
E2E_NC_GRAPHD_IMAGE: reg.vesoft-inc.com/vesoft-ent/nebula-graphd-ent | ||
E2E_NC_METAD_IMAGE: reg.vesoft-inc.com/vesoft-ent/nebula-metad-ent | ||
E2E_NC_STORAGED_IMAGE: reg.vesoft-inc.com/vesoft-ent/nebula-storaged-ent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
package envfuncsext | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/klog/v2" | ||
"sigs.k8s.io/e2e-framework/klient/wait" | ||
"sigs.k8s.io/e2e-framework/pkg/env" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
|
||
appsv1alpha1 "github.com/vesoft-inc/nebula-operator/apis/apps/v1alpha1" | ||
) | ||
|
||
type ( | ||
NebulaBackupInstallOptions struct { | ||
Name string | ||
Namespace string | ||
Spec appsv1alpha1.BackupSpec | ||
CronBackupOps *NebulaCronBackupOptions | ||
} | ||
|
||
NebulaCronBackupOptions struct { | ||
Schedule string | ||
TestPause bool | ||
} | ||
|
||
nebulaBackupCtxKey struct { | ||
backupType string | ||
} | ||
|
||
NebulaBackupCtxValue struct { | ||
// general fields | ||
Name string | ||
Namespace string | ||
BackupFileName string | ||
StorageType string | ||
BucketName string | ||
Region string | ||
CleanBackupData bool | ||
|
||
// for cron backup only | ||
Schedule string | ||
TestPause bool | ||
TriggeredBackupName string | ||
BackupSpec appsv1alpha1.BackupSpec | ||
} | ||
|
||
NebulaBackupOption func(*NebulaBackupOptions) | ||
NebulaBackupOptions struct { | ||
WaitOptions []wait.Option | ||
} | ||
) | ||
|
||
func DeployNebulaBackup(incremental bool, nbCtx NebulaBackupInstallOptions) env.Func { | ||
kevinliu24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
namespaceToUse := cfg.Namespace() | ||
if nbCtx.Namespace != "" { | ||
namespaceToUse = nbCtx.Namespace | ||
} | ||
|
||
nb := &appsv1alpha1.NebulaBackup{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: nbCtx.Name, | ||
Namespace: namespaceToUse, | ||
}, | ||
Spec: nbCtx.Spec, | ||
} | ||
|
||
ctx, err := CreateObject(nb)(ctx, cfg) | ||
if err != nil { | ||
return ctx, fmt.Errorf("error creating nebula backup [%v/%v]: %v", namespaceToUse, nbCtx.Name, err) | ||
} | ||
|
||
key := nebulaBackupCtxKey{backupType: "base"} | ||
if incremental { | ||
key = nebulaBackupCtxKey{backupType: "incr"} | ||
} | ||
|
||
var stoType, region, bucketName string | ||
if nb.Spec.Config.S3 != nil { | ||
stoType = "S3" | ||
region = nb.Spec.Config.S3.Region | ||
bucketName = nb.Spec.Config.S3.Bucket | ||
} else if nb.Spec.Config.GS != nil { | ||
stoType = "GS" | ||
region = nb.Spec.Config.GS.Location | ||
bucketName = nb.Spec.Config.GS.Bucket | ||
} | ||
|
||
return context.WithValue(ctx, key, &NebulaBackupCtxValue{ | ||
Name: nbCtx.Name, | ||
Namespace: namespaceToUse, | ||
StorageType: stoType, | ||
Region: region, | ||
BucketName: bucketName, | ||
CleanBackupData: *nb.Spec.CleanBackupData, | ||
}), nil | ||
} | ||
} | ||
|
||
func GetNebulaBackupCtxValue(incremental bool, ctx context.Context) *NebulaBackupCtxValue { | ||
key := nebulaBackupCtxKey{backupType: "base"} | ||
if incremental { | ||
key = nebulaBackupCtxKey{backupType: "incr"} | ||
} | ||
|
||
v := ctx.Value(key) | ||
data, _ := v.(*NebulaBackupCtxValue) | ||
return data | ||
} | ||
|
||
func WaitNebulaBackupFinished(incremental bool, opts ...NebulaBackupOption) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
o := (&NebulaBackupOptions{}).WithOptions(opts...) | ||
|
||
backupContextValue := GetNebulaBackupCtxValue(incremental, ctx) | ||
|
||
nb := &appsv1alpha1.NebulaBackup{} | ||
if err := wait.For(func(ctx context.Context) (done bool, err error) { | ||
err = cfg.Client().Resources().Get(ctx, backupContextValue.Name, backupContextValue.Namespace, nb) | ||
if err != nil { | ||
klog.ErrorS(err, "Get NebulaBackup failed", "namespace", backupContextValue.Namespace, "name", backupContextValue.Name) | ||
return true, err | ||
} | ||
|
||
klog.V(4).InfoS("Waiting for NebulaBackup to complete", | ||
"namespace", nb.Namespace, "name", nb.Name, | ||
"generation", nb.Generation, | ||
) | ||
|
||
if nb.Status.Phase == appsv1alpha1.BackupComplete { | ||
return true, nil | ||
} | ||
|
||
if nb.Status.Phase == appsv1alpha1.BackupFailed || nb.Status.Phase == appsv1alpha1.BackupInvalid { | ||
return true, fmt.Errorf("nebula backup [%v/%v] has failed", nb.Namespace, nb.Name) | ||
} | ||
|
||
return false, nil | ||
}, o.WaitOptions...); err != nil { | ||
klog.ErrorS(err, "Waiting for NebulaBackup to complete failed", "namespace", backupContextValue.Namespace, "name", backupContextValue.Name) | ||
return ctx, err | ||
} | ||
|
||
klog.InfoS("Waiting for NebulaBackup to complete successful", "namespace", backupContextValue.Namespace, "name", backupContextValue.Name, "backup file name", nb.Status.BackupName) | ||
|
||
key := nebulaBackupCtxKey{backupType: "base"} | ||
if incremental { | ||
key = nebulaBackupCtxKey{backupType: "incr"} | ||
} | ||
|
||
return context.WithValue(ctx, key, &NebulaBackupCtxValue{ | ||
Name: backupContextValue.Name, | ||
Namespace: backupContextValue.Namespace, | ||
BackupFileName: nb.Status.BackupName, | ||
StorageType: backupContextValue.StorageType, | ||
Region: backupContextValue.Region, | ||
BucketName: backupContextValue.BucketName, | ||
CleanBackupData: backupContextValue.CleanBackupData, | ||
}), nil | ||
} | ||
} | ||
|
||
func (o *NebulaBackupOptions) WithOptions(opts ...NebulaBackupOption) *NebulaBackupOptions { | ||
for _, opt := range opts { | ||
opt(o) | ||
} | ||
return o | ||
} | ||
|
||
func WithNebulaBackupWaitOptions(opts ...wait.Option) NebulaBackupOption { | ||
return func(o *NebulaBackupOptions) { | ||
o.WaitOptions = append(o.WaitOptions, opts...) | ||
} | ||
} | ||
|
||
func DeleteNebulaBackup(incremental bool) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
backupContextValue := GetNebulaBackupCtxValue(incremental, ctx) | ||
|
||
nb := &appsv1alpha1.NebulaBackup{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: backupContextValue.Name, | ||
Namespace: backupContextValue.Namespace, | ||
}, | ||
} | ||
|
||
ctx, err := DeleteObject(nb)(ctx, cfg) | ||
if err != nil { | ||
return ctx, fmt.Errorf("error deleting nebula backup [%v/%v]: %v", backupContextValue.Namespace, backupContextValue.Name, err) | ||
} | ||
|
||
return ctx, nil | ||
} | ||
} | ||
|
||
func WaitForCleanBackup(incremental bool, opts ...NebulaBackupOption) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
o := (&NebulaBackupOptions{}).WithOptions(opts...) | ||
|
||
backupContextValue := GetNebulaBackupCtxValue(incremental, ctx) | ||
|
||
nb := &appsv1alpha1.NebulaBackup{} | ||
if err := wait.For(func(ctx context.Context) (done bool, err error) { | ||
err = cfg.Client().Resources().Get(ctx, backupContextValue.Name, backupContextValue.Namespace, nb) | ||
if err != nil { | ||
if apierrors.IsNotFound(err) { | ||
return true, nil | ||
} | ||
return true, fmt.Errorf("error deleting nebula backup [%v/%v]: %v", backupContextValue.Namespace, backupContextValue.Name, err) | ||
} | ||
|
||
if nb.Status.Phase == appsv1alpha1.BackupComplete || nb.Status.Phase == appsv1alpha1.BackupClean { | ||
klog.V(4).InfoS("Waiting for NebulaBackup cleanup to complete", | ||
"namespace", nb.Namespace, "name", nb.Name, "file name", backupContextValue.BackupFileName, | ||
"generation", nb.Generation, | ||
) | ||
return false, nil | ||
} | ||
|
||
return true, fmt.Errorf("nebula backup clean for [%v/%v] has failed", backupContextValue.Namespace, backupContextValue.Name) | ||
}, o.WaitOptions...); err != nil { | ||
klog.ErrorS(err, "Waiting for NebulaBackup clean to complete failed", "namespace", backupContextValue.Namespace, "name", backupContextValue.Name, "file name", backupContextValue.BackupFileName) | ||
return ctx, err | ||
} | ||
klog.InfoS("Waiting for NebulaBackup clean to complete successful", "namespace", backupContextValue.Namespace, "name", backupContextValue.Name, "file name", backupContextValue.BackupFileName) | ||
|
||
return ctx, nil | ||
} | ||
} | ||
|
||
func CreateServiceAccount(namespace, name string) env.Func { | ||
kevinliu24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
sa := &corev1.ServiceAccount{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: name, | ||
Namespace: namespace, | ||
}, | ||
} | ||
|
||
if ctx, err := CreateObject(sa)(ctx, cfg); err != nil { | ||
if apierrors.IsAlreadyExists(err) { | ||
klog.Infof("service account [%s/%s] already exists", sa.Namespace, sa.Name) | ||
return ctx, nil | ||
} | ||
return ctx, err | ||
} | ||
|
||
klog.Infof("Service account [%s/%s] created successfully", namespace, name) | ||
return ctx, nil | ||
} | ||
} | ||
|
||
func DeleteServiceAccount(namespace, name string) env.Func { | ||
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) { | ||
sa := &corev1.ServiceAccount{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: name, | ||
Namespace: namespace, | ||
}, | ||
} | ||
|
||
if err := cfg.Client().Resources().Delete(ctx, sa); err != nil { | ||
return ctx, err | ||
} | ||
|
||
klog.Infof("Service account [%s/%s] deleted successfully", namespace, name) | ||
return ctx, nil | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why put it in
cloud-dev
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently br-ent is in cloud-dev. @MegaByte875 to move them into the CI folder