[ 
https://issues.apache.org/jira/browse/BEAM-13873?focusedWorklogId=733770&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-733770
 ]

ASF GitHub Bot logged work on BEAM-13873:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Feb/22 08:41
            Start Date: 28/Feb/22 08:41
    Worklog Time Spent: 10m 
      Work Description: AydarZaynutdinov commented on a change in pull request 
#16946:
URL: https://github.com/apache/beam/pull/16946#discussion_r815669173



##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -46,8 +50,14 @@ func setup() error {
        if err != nil {
                return err
        }
-       filePath := filepath.Join(configFolderName, defaultSdk.String()+jsonExt)
-       err = os.WriteFile(filePath, []byte(javaConfig), 0600)
+       javaConfigPath := filepath.Join(configFolderName, 
defaultSdk.String()+jsonExt)
+       err = os.WriteFile(javaConfigPath, []byte(javaConfig), 0600)
+       goConfigPath := filepath.Join(configFolderName, 
pb.Sdk_SDK_GO.String()+jsonExt)
+       err = os.WriteFile(goConfigPath, []byte(goConfig), 0600)
+       pythonConfigPath := filepath.Join(configFolderName, 
pb.Sdk_SDK_PYTHON.String()+jsonExt)
+       err = os.WriteFile(pythonConfigPath, []byte(pythonConfig), 0600)
+       scioConfigPath := filepath.Join(configFolderName, 
pb.Sdk_SDK_SCIO.String()+jsonExt)
+       err = os.WriteFile(scioConfigPath, []byte(scioConfig), 0600)

Review comment:
       Move `0600` as a constant.

##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -308,3 +344,109 @@ func Test_getConfigFromJson(t *testing.T) {
                })
        }
 }
+
+func TestConfigureBeamEnvs(t *testing.T) {
+       workingDir := "./"
+       modDir := "/modDir"
+       goExecutorConfig := NewExecutorConfig(
+               "go",
+               "",
+               "go",
+               []string{"build", "-o", "bin"},
+               []string{},
+               []string{"test", "-v"},
+       )
+       pythonExecutorConfig := NewExecutorConfig(
+               "",
+               "python3",
+               "pytest",
+               []string{},
+               []string{},
+               []string{},
+       )
+       scioExecutorConfig := NewExecutorConfig(
+               "",
+               "sbt",
+               "sbt",
+               []string{},
+               []string{"runMain"},
+               []string{},
+       )
+       type args struct {
+               workingDir string
+       }
+       tests := []struct {
+               name      string
+               args      args
+               want      *BeamEnvs
+               wantErr   bool
+               envsToSet map[string]string
+       }{
+               {
+                       name:      "PREPARED_MOD_DIR is not specified in the 
environment for GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO"},
+               },
+               {
+                       name:      "BeamSdkKey set to GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      NewBeamEnvs(pb.Sdk_SDK_GO, goExecutorConfig, 
modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO", 
preparedModDirKey: modDir},
+               },
+               {
+                       name:      "Error during creating executable config",
+                       args:      args{workingDir: "/app"},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to Python sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to SCIO sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_SCIO, 
scioExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_SCIO"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with a 
positive number",

Review comment:
       ```suggestion
                        name:      "NumOfParallelJobsKey is set with a positive 
number",
   ```

##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -308,3 +344,109 @@ func Test_getConfigFromJson(t *testing.T) {
                })
        }
 }
+
+func TestConfigureBeamEnvs(t *testing.T) {
+       workingDir := "./"
+       modDir := "/modDir"
+       goExecutorConfig := NewExecutorConfig(
+               "go",
+               "",
+               "go",
+               []string{"build", "-o", "bin"},
+               []string{},
+               []string{"test", "-v"},
+       )
+       pythonExecutorConfig := NewExecutorConfig(
+               "",
+               "python3",
+               "pytest",
+               []string{},
+               []string{},
+               []string{},
+       )
+       scioExecutorConfig := NewExecutorConfig(
+               "",
+               "sbt",
+               "sbt",
+               []string{},
+               []string{"runMain"},
+               []string{},
+       )
+       type args struct {
+               workingDir string
+       }
+       tests := []struct {
+               name      string
+               args      args
+               want      *BeamEnvs
+               wantErr   bool
+               envsToSet map[string]string
+       }{
+               {
+                       name:      "PREPARED_MOD_DIR is not specified in the 
environment for GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO"},
+               },
+               {
+                       name:      "BeamSdkKey set to GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      NewBeamEnvs(pb.Sdk_SDK_GO, goExecutorConfig, 
modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO", 
preparedModDirKey: modDir},
+               },
+               {
+                       name:      "Error during creating executable config",
+                       args:      args{workingDir: "/app"},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to Python sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to SCIO sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_SCIO, 
scioExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_SCIO"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with a 
positive number",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, 1),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON", 
numOfParallelJobsKey: "1"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with a 
negative number",

Review comment:
       ```suggestion
                        name:      "NumOfParallelJobsKey is set with a negative 
number",
   ```

##########
File path: playground/backend/internal/environment/environment_service_test.go
##########
@@ -308,3 +344,109 @@ func Test_getConfigFromJson(t *testing.T) {
                })
        }
 }
+
+func TestConfigureBeamEnvs(t *testing.T) {
+       workingDir := "./"
+       modDir := "/modDir"
+       goExecutorConfig := NewExecutorConfig(
+               "go",
+               "",
+               "go",
+               []string{"build", "-o", "bin"},
+               []string{},
+               []string{"test", "-v"},
+       )
+       pythonExecutorConfig := NewExecutorConfig(
+               "",
+               "python3",
+               "pytest",
+               []string{},
+               []string{},
+               []string{},
+       )
+       scioExecutorConfig := NewExecutorConfig(
+               "",
+               "sbt",
+               "sbt",
+               []string{},
+               []string{"runMain"},
+               []string{},
+       )
+       type args struct {
+               workingDir string
+       }
+       tests := []struct {
+               name      string
+               args      args
+               want      *BeamEnvs
+               wantErr   bool
+               envsToSet map[string]string
+       }{
+               {
+                       name:      "PREPARED_MOD_DIR is not specified in the 
environment for GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO"},
+               },
+               {
+                       name:      "BeamSdkKey set to GO sdk",
+                       args:      args{workingDir: workingDir},
+                       want:      NewBeamEnvs(pb.Sdk_SDK_GO, goExecutorConfig, 
modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_GO", 
preparedModDirKey: modDir},
+               },
+               {
+                       name:      "Error during creating executable config",
+                       args:      args{workingDir: "/app"},
+                       want:      nil,
+                       wantErr:   true,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to Python sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON"},
+               },
+               {
+                       name:      "BeamSdkKey set to SCIO sdk",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_SCIO, 
scioExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_SCIO"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with a 
positive number",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, 1),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON", 
numOfParallelJobsKey: "1"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with a 
negative number",
+                       want:      NewBeamEnvs(pb.Sdk_SDK_PYTHON, 
pythonExecutorConfig, modDir, defaultNumOfParallelJobs),
+                       wantErr:   false,
+                       envsToSet: map[string]string{beamSdkKey: "SDK_PYTHON", 
numOfParallelJobsKey: "-1"},
+               },
+               {
+                       name:      "NumOfParallelJobsKey is set with with 
incorrect value",

Review comment:
       ```suggestion
                        name:      "NumOfParallelJobsKey is set with incorrect 
value",
   ```




-- 
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: 733770)
    Time Spent: 1h  (was: 50m)

> [Playground] Increase test coverage for the environment package
> ---------------------------------------------------------------
>
>                 Key: BEAM-13873
>                 URL: https://issues.apache.org/jira/browse/BEAM-13873
>             Project: Beam
>          Issue Type: Sub-task
>          Components: beam-playground
>            Reporter: Aydar Zaynutdinov
>            Assignee: Pavel Avilov
>            Priority: P3
>              Labels: beam-playground-backend
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Need to add unit tests to increase the test coverage for the _environment_ 
> package.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to