[
https://issues.apache.org/jira/browse/BEAM-13398?focusedWorklogId=707309&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-707309
]
ASF GitHub Bot logged work on BEAM-13398:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 12/Jan/22 07:36
Start Date: 12/Jan/22 07:36
Worklog Time Spent: 10m
Work Description: daria-malkova commented on a change in pull request
#16374:
URL: https://github.com/apache/beam/pull/16374#discussion_r782776329
##########
File path: playground/backend/internal/fs_tool/fs_test.go
##########
@@ -30,132 +28,108 @@ import (
const (
sourceDir = "sourceDir"
destinationDir = "destinationDir"
+ testFileMode = 0755
pipelinesFolder = "executable_files"
)
-func TestMain(m *testing.M) {
- err := setupPreparedFiles()
- if err != nil {
- logger.Fatal(err)
- }
- defer teardown()
- m.Run()
-}
-
-func setupPreparedFiles() error {
- err := os.Mkdir(sourceDir, 0755)
+func prepareFiles() error {
+ err := os.Mkdir(sourceDir, testFileMode)
if err != nil {
return err
}
- err = os.Mkdir(destinationDir, 0755)
+ err = os.Mkdir(destinationDir, testFileMode)
if err != nil {
return err
}
filePath := filepath.Join(sourceDir, "file.txt")
_, err = os.Create(filePath)
- if err != nil {
- return err
- }
- return nil
+ return err
}
-func teardown() {
+func teardownFiles() error {
err := os.RemoveAll(sourceDir)
if err != nil {
- logger.Fatal(err)
- }
- err = os.RemoveAll(destinationDir)
- if err != nil {
- logger.Fatal(err)
- }
- err = os.RemoveAll(pipelinesFolder)
- if err != nil {
- logger.Fatal(err)
+ return err
}
+ return os.RemoveAll(destinationDir)
}
-func TestLifeCycle_CreateExecutableFile(t *testing.T) {
- pipelineId := uuid.New()
- baseFileFolder := fmt.Sprintf("%s/%s", pipelinesFolder, pipelineId)
- srcFileFolder := baseFileFolder + "/src"
- binFileFolder := baseFileFolder + "/bin"
+func prepareFolders(baseFileFolder string) error {
+ srcFileFolder := filepath.Join(baseFileFolder, "src")
+
+ return os.MkdirAll(srcFileFolder, testFileMode)
+}
+
+func teardownFolders(baseFileFolder string) error {
Review comment:
Why have you divided teardown to two methods?
##########
File path: playground/backend/internal/fs_tool/fs.go
##########
@@ -92,26 +86,17 @@ func (l *LifeCycle) DeleteFolders() error {
}
// CreateSourceCodeFile creates an executable file (i.e.
file.{sourceFileExtension}).
-func (l *LifeCycle) CreateSourceCodeFile(code string) (string, error) {
- if _, err := os.Stat(l.Folder.SourceFileFolder); os.IsNotExist(err) {
- return "", err
+func (l *LifeCycle) CreateSourceCodeFile(code string) error {
+ if _, err := os.Stat(l.Paths.AbsoluteSourceFileFolderPath);
os.IsNotExist(err) {
+ return err
}
- fileName := l.pipelineId.String() + l.Extension.SourceFileExtension
- filePath := filepath.Join(l.Folder.SourceFileFolder, fileName)
+ filePath := l.Paths.AbsoluteSourceFilePath
Review comment:
Can we use _lc_ instead of _l_? To make it equal everywhere?
##########
File path: playground/backend/internal/fs_tool/fs_test.go
##########
@@ -30,132 +28,108 @@ import (
const (
sourceDir = "sourceDir"
destinationDir = "destinationDir"
+ testFileMode = 0755
pipelinesFolder = "executable_files"
)
-func TestMain(m *testing.M) {
- err := setupPreparedFiles()
- if err != nil {
- logger.Fatal(err)
- }
- defer teardown()
- m.Run()
-}
-
-func setupPreparedFiles() error {
- err := os.Mkdir(sourceDir, 0755)
+func prepareFiles() error {
+ err := os.Mkdir(sourceDir, testFileMode)
if err != nil {
return err
}
- err = os.Mkdir(destinationDir, 0755)
+ err = os.Mkdir(destinationDir, testFileMode)
if err != nil {
return err
}
filePath := filepath.Join(sourceDir, "file.txt")
_, err = os.Create(filePath)
- if err != nil {
- return err
- }
- return nil
+ return err
}
-func teardown() {
+func teardownFiles() error {
Review comment:
Why have you decided to change the method name? _teardown_ is common
name
##########
File path: playground/backend/internal/fs_tool/lc_constructor.go
##########
@@ -30,35 +30,51 @@ func newCompilingLifeCycle(pipelineId uuid.UUID,
pipelinesFolder, sourceFileExte
baseFileFolder := filepath.Join(pipelinesFolder, pipelineId.String())
srcFileFolder := filepath.Join(baseFileFolder, sourceFolderName)
binFileFolder := filepath.Join(baseFileFolder, compiledFolderName)
+
+ srcFileName := pipelineId.String() + sourceFileExtension
+ absSrcFileFolderPath, _ := filepath.Abs(srcFileFolder)
+ absSrcFilePath, _ := filepath.Abs(filepath.Join(absSrcFileFolderPath,
srcFileName))
Review comment:
Don't you need to process errors somehow?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 707309)
Time Spent: 50m (was: 40m)
> [Playground] Split LifeCycle to DTO and business logic
> ------------------------------------------------------
>
> Key: BEAM-13398
> URL: https://issues.apache.org/jira/browse/BEAM-13398
> Project: Beam
> Issue Type: Improvement
> Components: beam-playground
> Reporter: Ilya Kozyrev
> Assignee: Aydar Zaynutdinov
> Priority: P2
> Labels: beam-playground-backend
> Time Spent: 50m
> Remaining Estimate: 0h
>
> Currently, we need to pass to methods tons of arguments or complete LifeCycle
> object. In the second path, we give paths required for different methods with
> all business logic contained in the Lifecycle.
>
> We need to split DTO and business logic to make the code more secure and
> straightforward. DTO might be composited with Lifecycle if necessary.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)