googleapis / googleapis/google-cloud-java

[java-datastore] Starting LocalDatastoreHelper stalls if `beta` gcloud component is not installed

Đang mở
#12,002 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: datastore lang: java priority: p3 status: blocked type: bug
Ngôn ngữ chính
Java
Star
2.1k
Fork
1.2k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
154

Mô tả

#### Environment details
- OS type and version: Debian GNU/Linux 10 (buster) (on Docker)
- Java version: openjdk version "1.8.0_275"
- datastore version(s): com.google.cloud:google-cloud-datastore:jar:1.105.0

#### Steps to reproduce

1. Remove `beta` component: `gcloud components remove beta`
2. Run the code which uses `LocalDatastoreHelper`

#### Code example

```java
import com.google.cloud.datastore.testing.LocalDatastoreHelper;

public class Test {
public static void main(String[] args) throws Exception {
LocalDatastoreHelper emulator = LocalDatastoreHelper.create();
emulator.start();

System.out.println("Started!");
}
}
```

#### How I found this

- Removed `beta` component
```
root@17224e8a6010:/app# gcloud components remove beta --quiet
┌──────────────────────────────────────────┐
│ These components will be removed. │
├──────────────────────┬────────────┬──────┤
│ Name │ Version │ Size │
├──────────────────────┼────────────┼──────┤
│ gcloud Beta Commands │ 2019.05.17 │ │
└──────────────────────┴────────────┴──────┘
...
Uninstall done!
```

- Run code example, then it stalls.
```
root@17224e8a6010:/app# mvn exec:java -Dexec.mainClass=Test
```

- `Ctrl+Z` and run `ps` to find out what command is executed via LocalDatastoreHelper
```
^Z
[1]+ Stopped mvn exec:java -Dexec.mainClass=Test
root@17224e8a6010:/app# ps -ef
...
root 1840 1795 0 17:40 pts/1 00:00:00 python2 -S /root/google-cloud-sdk/lib/gcloud.py beta emulators datastore start --host-port=localhost:40079 --consistency=0.9
```

- Execute the same command at the terminal, then it prompts whether continue to install `beta` component
```
root@17224e8a6010:/app# python2 -S /root/google-cloud-sdk/lib/gcloud.py beta emulators datastore start --host-port=localhost:40079 --consistency=0.9
You do not currently have this command group installed. Using it
requires the installation of components: [beta]

Your current Cloud SDK version is: 322.0.0
Installing components from version: 322.0.0

┌─────────────────────────────────────────────┐
│ These components will be installed. │
├──────────────────────┬────────────┬─────────┤
│ Name │ Version │ Size │
├──────────────────────┼────────────┼─────────┤
│ gcloud Beta Commands │ 2019.05.17 │ < 1 MiB │
└──────────────────────┴────────────┴─────────┘

For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?
```

#### Possible solution

Add `--quiet` option to run emulator, so as to silently install `beta` component.
https://github.com/pomu0325/java-datastore/commit/e2cb8f26e977c6c220ba047fe28f4ca1c3da7d40

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.