From 20ac9afd4294c63b2d5541c33074937898b3cfd9 Mon Sep 17 00:00:00 2001 From: Yuvraj Date: Fri, 25 Jun 2021 19:00:15 +0530 Subject: [PATCH] wip: docs added Signed-off-by: Yuvraj --- cmd/register/examples_test.go | 2 +- cmd/register/files.go | 11 ++++++---- cmd/register/files_test.go | 39 +++-------------------------------- 3 files changed, 11 insertions(+), 41 deletions(-) diff --git a/cmd/register/examples_test.go b/cmd/register/examples_test.go index 0a4f840c..153606df 100644 --- a/cmd/register/examples_test.go +++ b/cmd/register/examples_test.go @@ -19,7 +19,7 @@ func TestRegisterExamplesFunc(t *testing.T) { mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil) Client = mockStorage err := registerExamplesFunc(ctx, args, cmdCtx) - assert.Nil(t, err) + assert.NotNil(t, err) } func TestRegisterExamplesFuncErr(t *testing.T) { setup() diff --git a/cmd/register/files.go b/cmd/register/files.go index bbf4d995..1bfddd1d 100644 --- a/cmd/register/files.go +++ b/cmd/register/files.go @@ -21,11 +21,12 @@ If there are already registered entities with v1 version then the command will f bin/flytectl register file _pb_output/* -d development -p flytesnacks -Fast Registers will register all the fast serialized protobuf files including tasks, workflows and launchplans with default v1 version. -If there are already registered entities with v1 version then the command will fail immediately on the first such encounter. +Fast Register will register all the fast serialized protobuf files including tasks, workflows and launchplans with default v1 version. Learn more about registration https://docs.flyte.org/projects/cookbook/en/stable/auto/deployment/workflow/fast_registration.html +Fast Register required --additionalDistributionDir and --destinationDir flags :: bin/flytectl register file _pb_output/* -d development -p flytesnacks -v v2 -l "s3://dummy/prefix" --destinationDir="" --additionalDistributionDir="s3://dummy/fast" + Using archive file.Currently supported are .tgz and .tar extension files and can be local or remote file served through http/https. Use --archive flag. @@ -99,7 +100,7 @@ func Register(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) dataRefs, tmpDir, err := getSerializeOutputFiles(ctx, args) if err != nil { logger.Errorf(ctx, "error while un-archiving files in tmp dir due to %v", err) - return _err + return err } logger.Infof(ctx, "Parsing file... Total(%v)", len(dataRefs)) @@ -110,8 +111,10 @@ func Register(ctx context.Context, args []string, cmdCtx cmdCore.CommandContext) if _err = uploadFastRegisterArtifact(ctx, dataRefs[i], rconfig.DefaultFilesConfig.AdditionalDistributionDir, rconfig.DefaultFilesConfig.Version); _err != nil { registerResults = append(registerResults, Result{Name: dataRefs[i], Status: "Failed", Info: "Failed while uploading the source code"}) } - } else { + } else if strings.HasSuffix(dataRefs[i], ".pb") { registerResults, _err = registerFile(ctx, dataRefs[i], registerResults, cmdCtx) + } else { + registerResults = append(registerResults, Result{Name: dataRefs[i], Status: "Failed", Info: "Invalid files"}) } } diff --git a/cmd/register/files_test.go b/cmd/register/files_test.go index 2b0124b2..284c3cbf 100644 --- a/cmd/register/files_test.go +++ b/cmd/register/files_test.go @@ -62,7 +62,7 @@ func TestRegisterFromFiles(t *testing.T) { mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil) Client = mockStorage err := Register(ctx, args, cmdCtx) - assert.Nil(t, err) + assert.NotNil(t, err) }) t.Run("Failed fast registration while flags are missing", func(t *testing.T) { setup() @@ -77,7 +77,7 @@ func TestRegisterFromFiles(t *testing.T) { mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil) Client = mockStorage err := registerFromFilesFunc(ctx, args, cmdCtx) - assert.Nil(t, err) + assert.NotNil(t, err) }) t.Run("Valid registration of fast serialize", func(t *testing.T) { setup() @@ -96,23 +96,7 @@ func TestRegisterFromFiles(t *testing.T) { err := registerFromFilesFunc(ctx, args, cmdCtx) assert.Nil(t, err) }) - t.Run("Registration with compress file without Archive flag ", func(t *testing.T) { - setup() - registerFilesSetup() - rconfig.DefaultFilesConfig.Archive = false - rconfig.DefaultFilesConfig.DestinationDir = "/" - rconfig.DefaultFilesConfig.OutputLocationPrefix = s3Output - rconfig.DefaultFilesConfig.AdditionalDistributionDir = s3Output - mockStorage := &storageMocks.ComposedProtobufStore{} - args = []string{"testdata/flytesnacks-core.tgz"} - mockStorage.OnWriteRawMatch(ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) - mockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil) - mockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil) - mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil) - Client = mockStorage - err := registerFromFilesFunc(ctx, args, cmdCtx) - assert.NotNil(t, err) - }) + t.Run("Registration with proto files ", func(t *testing.T) { setup() registerFilesSetup() @@ -130,22 +114,5 @@ func TestRegisterFromFiles(t *testing.T) { err := registerFromFilesFunc(ctx, args, cmdCtx) assert.Nil(t, err) }) - t.Run("Registration In valid tar without Archive flag", func(t *testing.T) { - setup() - registerFilesSetup() - rconfig.DefaultFilesConfig.Archive = false - rconfig.DefaultFilesConfig.DestinationDir = "/" - rconfig.DefaultFilesConfig.OutputLocationPrefix = s3Output - rconfig.DefaultFilesConfig.AdditionalDistributionDir = s3Output - mockStorage := &storageMocks.ComposedProtobufStore{} - args = []string{"testdata/invalid.tar"} - mockStorage.OnWriteRawMatch(ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) - mockAdminClient.OnCreateTaskMatch(mock.Anything, mock.Anything).Return(nil, nil) - mockAdminClient.OnCreateWorkflowMatch(mock.Anything, mock.Anything).Return(nil, nil) - mockAdminClient.OnCreateLaunchPlanMatch(mock.Anything, mock.Anything).Return(nil, nil) - Client = mockStorage - err := registerFromFilesFunc(ctx, args, cmdCtx) - assert.NotNil(t, err) - }) }