diff --git a/engine/pkg/externalresource/broker/storage_handle_test.go b/engine/pkg/externalresource/broker/storage_handle_test.go index 6053d895bca..14eed1e9c7f 100644 --- a/engine/pkg/externalresource/broker/storage_handle_test.go +++ b/engine/pkg/externalresource/broker/storage_handle_test.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/tiflow/engine/pkg/externalresource/internal/local" "github.com/pingcap/tiflow/engine/pkg/externalresource/manager" resModel "github.com/pingcap/tiflow/engine/pkg/externalresource/model" - "github.com/pingcap/tiflow/engine/pkg/externalresource/model" "github.com/pingcap/tiflow/engine/pkg/tenant" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -33,7 +32,7 @@ func newResourceIdentForTesting(executor, workerID, resourceName string) interna Name: resModel.EncodeResourceName(resourceName), ResourceScope: internal.ResourceScope{ ProjectInfo: tenant.NewProjectInfo("fakeTenant", "fakeProject"), - Executor: model.ExecutorID(executor), + Executor: resModel.ExecutorID(executor), WorkerID: workerID, }, } @@ -43,9 +42,9 @@ func TestStorageHandlePersistAndDiscard(t *testing.T) { t.Parallel() dir := t.TempDir() - executor := model.ExecutorID("executor-1") + executor := resModel.ExecutorID("executor-1") ident := newResourceIdentForTesting(string(executor), "worker-1", "test-resource") - fm := local.NewLocalFileManager(executor, model.LocalFileConfig{BaseDir: dir}) + fm := local.NewLocalFileManager(executor, resModel.LocalFileConfig{BaseDir: dir}) cli := manager.NewMockClient() ctx := context.Background() @@ -109,7 +108,7 @@ func TestStorageHandlePersistAndDiscard(t *testing.T) { func TestStorageHandleDiscardTemporaryResource(t *testing.T) { t.Parallel() dir := t.TempDir() - fm := local.NewLocalFileManager("", model.LocalFileConfig{BaseDir: dir}) + fm := local.NewLocalFileManager("", resModel.LocalFileConfig{BaseDir: dir}) cli := manager.NewMockClient() ctx := context.Background() diff --git a/engine/pkg/externalresource/internal/s3/s3_dummy_resouce.go b/engine/pkg/externalresource/internal/s3/s3_dummy_resouce.go index 0591667b7fb..14809174aa4 100644 --- a/engine/pkg/externalresource/internal/s3/s3_dummy_resouce.go +++ b/engine/pkg/externalresource/internal/s3/s3_dummy_resouce.go @@ -63,6 +63,7 @@ func GetDummyJobID(executorID model.ExecutorID) model.JobID { return fmt.Sprintf(dummyJobID, executorID) } +// GetDummyResPath returns a file path located in dummy resource for s3 storage. func GetDummyResPath(filename string) string { return path.Join(DummyWorkerID, dummyResourceName, filename) } diff --git a/engine/pkg/externalresource/model/model.go b/engine/pkg/externalresource/model/model.go index 84d79c83288..1148b04288c 100644 --- a/engine/pkg/externalresource/model/model.go +++ b/engine/pkg/externalresource/model/model.go @@ -16,10 +16,10 @@ package model import ( "encoding/hex" "fmt" - "log" "path" "strings" + "github.com/pingcap/log" pb "github.com/pingcap/tiflow/engine/enginepb" "github.com/pingcap/tiflow/engine/model" ormModel "github.com/pingcap/tiflow/engine/pkg/orm/model" @@ -183,7 +183,7 @@ func BuildResourceID(rtype ResourceType, resName ResourceName) ResourceID { // EncodeResourceName encodes raw resource name to a valid resource name. func EncodeResourceName(rawResName string) ResourceName { resName := hex.EncodeToString([]byte(rawResName)) - return ResourceName(resName) + return resName } // DecodeResourceName decodes resource name to raw resource name. diff --git a/engine/pkg/externalresource/model/model_test.go b/engine/pkg/externalresource/model/model_test.go index f4e8ac0f9b7..a844ddd6180 100644 --- a/engine/pkg/externalresource/model/model_test.go +++ b/engine/pkg/externalresource/model/model_test.go @@ -26,7 +26,6 @@ func TestParseResource(t *testing.T) { rawResName, err := DecodeResourceName(suffix) require.NoError(t, err) require.Equal(t, "my-local-resource/a/b/c", rawResName) - require.Equal(t, "/local/my-local-resource/a/b/c", BuildResourceID(tp, suffix)) tp, suffix, err = ParseResourceID("/s3/my-local-resource/a/b/c") @@ -35,18 +34,9 @@ func TestParseResource(t *testing.T) { rawResName, err = DecodeResourceName(suffix) require.NoError(t, err) require.Equal(t, "my-local-resource/a/b/c", rawResName) - require.Equal(t, "/s3/my-local-resource/a/b/c", BuildResourceID(tp, suffix)) } -func TestResourceName(t *testing.T) { - name := "resource-1" - resName := EncodeResourceName(name) - parsedName, err := DecodeResourceName(resName) - require.NoError(t, err) - require.Equal(t, name, parsedName) -} - func FuzzEncodeResourceName(f *testing.F) { testcases := []string{"resource-1", "resource-1/inner", "!resource-1+-%/*inner"} for _, tc := range testcases {