You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "damccorm (via GitHub)" <gi...@apache.org> on 2023/03/22 19:48:05 UTC
[GitHub] [beam] damccorm commented on a diff in pull request #24946: [Playground] Resolve issue with SCIO examples failing on start due to a timeout
damccorm commented on code in PR #24946:
URL: https://github.com/apache/beam/pull/24946#discussion_r1145329122
##########
playground/backend/internal/utils/preparers_utils_test.go:
##########
@@ -27,6 +27,61 @@ import (
"testing"
)
+const (
+ sourceDir = "sourceDir"
+ fileName = "file.txt"
+ fileContent = "content"
+ testDataDir = "test_data"
+ javaFileName = "JavaFileName.java"
+ emptyFileName = "emptyFile.java"
+ pythonExampleName = "wordcount.py"
+ filePermission = 0600
+ fullPermission = 0755
+)
+
+func TestMain(m *testing.M) {
+ err := setup()
+ if err != nil {
+ panic(fmt.Errorf("error during test setup: %s", err.Error()))
+ }
+ defer teardown()
+ m.Run()
+}
+
+func setup() error {
+ err := os.Mkdir(sourceDir, fullPermission)
+ if err != nil {
+ return err
+ }
+ filePath := filepath.Join(sourceDir, fileName)
+ err = os.WriteFile(filePath, []byte(fileContent), filePermission)
+ if err != nil {
+ return err
+ }
+ sourceJavaFilePath := filepath.Join(testDataDir, javaFileName)
+ javaFilePath := filepath.Join(sourceDir, javaFileName)
+ err = CopyFile(sourceJavaFilePath, javaFilePath)
+ if err != nil {
+ return err
+ }
+ if err != nil {
+ return err
+ }
Review Comment:
```suggestion
if err != nil {
return err
}
```
##########
playground/backend/README.md:
##########
@@ -27,43 +27,84 @@ no setup.
## Getting Started
-See [playground/README.md](../README.md) for details on requirements and setup.
+See [playground/README.md](../README.md) for details on installing development dependencies.
This section describes what is needed to run the backend application.
- Go commands to run/test the backend locally
- Set up environment variables to run the backend locally
- Running the backend via Docker
-### Go commands to run/test application locally
+## Go commands to run/test application locally
+### Prerequisite
+
+> **Google Cloud Shell note:** `start_datastore_emulator.sh` script makes use of `nc` and `lsof` commands which are not installed on Google Cloud Shell machines. You can install them using `sudo apt install netcat lsof`.
+
+> **Google Cloud Shell note:** run `unset GOOGLE_CLOUD_PROJECT` before running tests so they would use locally running datastore emulator.
+
+Start datastore emulator
+```shell
+bash start_datastore_emulator.sh
+```
+
+After you have finished running tests
+```shell
+bash stop_datastore_emulator.sh
+```
+
+### Run/build
Go to the backend directory:
```shell
-$ cd backend
+cd backend
```
-The following command is used to build and serve the backend locally:
+To run backend server on development machine without using docker you'll need first to prepare a working directory anywhere outside of Beam source tree:
+```shell
+mkdir ~/path/to/workdir
+```
+and then copy `datasets/` and `configs/` and `logging.properties` from [`playground/backend/`](/playground/backend/) directory:
+```shell
+cp -r {logging.properties,datasets/,configs/} ~/path/to/workdir
+```
+In case if you want to start backend for Go SDK you additionally will also need to create a prepared mod dir and export an additional environment variable:
```shell
-$ go run ./cmd/server/server.go
+export PREPARED_MOD_DIR=~/path/to/workdir/prepared_folder
+SDK_TAG=2.44.0 bash ./containers/go/setup_sdk.sh $PREPARED_MOD_DIR
```
+The following command will build and serve the backend locally:
+
+```shell
+SERVER_PORT=<port> \
+BEAM_SDK=<beam_sdk_type> \
+APP_WORK_DIR=<path_to_workdir> \
+DATASTORE_EMULATOR_HOST=127.0.0.1:8888 \
+DATASTORE_PROJECT_ID=test \
+SDK_CONFIG=../sdks-emulator.yaml \
+go run ./cmd/server
+```
+
+where `<port>` should be the value of port on which you want to have the backend server availalbe; `<beam_sdk_type>` is a value of desired Beam SDK, possible values are `SDK_UNSPECIFIED`, `SDK_JAVA`, `SDK_PYTHON`, `SDK_GO`, `SDK_SCIO`; `<path_to_workdir>` should be set to path to yoru work dir, e.g. `~/path/to/workdir`.
Review Comment:
```suggestion
where `<port>` should be the value of port on which you want to have the backend server available; `<beam_sdk_type>` is a value of desired Beam SDK, possible values are `SDK_UNSPECIFIED`, `SDK_JAVA`, `SDK_PYTHON`, `SDK_GO`, `SDK_SCIO`; `<path_to_workdir>` should be set to path to your work dir, e.g. `~/path/to/workdir`.
```
nit
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org