瀏覽代碼

Set and test proper network state on startup

pull/20/head
Kristijan Mitrovic 4 年之前
父節點
當前提交
bbea6c4451
共有 3 個檔案被更改,包括 29 行新增3 行删除
  1. +7
    -0
      bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java
  2. +6
    -0
      bubble-server/src/test/resources/models/include/new_bubble.json
  3. +16
    -3
      bubble-server/src/test/resources/models/tests/live/backup_and_restore.json

+ 7
- 0
bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java 查看文件

@@ -7,6 +7,7 @@ package bubble.server.listener;
import bubble.ApiConstants;
import bubble.dao.account.AccountDAO;
import bubble.dao.account.AccountPolicyDAO;
import bubble.dao.cloud.BubbleNetworkDAO;
import bubble.model.account.Account;
import bubble.model.account.AccountPolicy;
import bubble.model.account.message.AccountAction;
@@ -14,6 +15,7 @@ import bubble.model.account.message.AccountMessage;
import bubble.model.account.message.AccountMessageType;
import bubble.model.account.message.ActionTarget;
import bubble.model.cloud.BubbleNetwork;
import bubble.model.cloud.BubbleNetworkState;
import bubble.server.BubbleConfiguration;
import bubble.service.boot.SageHelloService;
import lombok.extern.slf4j.Slf4j;
@@ -78,6 +80,11 @@ public class BubbleFirstTimeListener extends RestServerLifecycleListenerBase<Bub
.setAction(AccountAction.verify)
.setTarget(ActionTarget.network)
.setData(unlockKey));

if (network.getState().equals(BubbleNetworkState.starting)) {
network.setState(BubbleNetworkState.running);
configuration.getBean(BubbleNetworkDAO.class).update(network);
}
} finally {
if (!FIRST_TIME_FILE.delete()) {
log.error("onStart: error deleting: "+abs(FIRST_TIME_FILE));


+ 6
- 0
bubble-server/src/test/resources/models/include/new_bubble.json 查看文件

@@ -219,5 +219,11 @@
{"condition": "json.admin() == true"}
]
}
},

{
"comment": "network should be in running state by now",
"request": { "uri": "me/networks/<<network>>" },
"response": { "check": [{ "condition": "json.getState().name() == 'running'" }] }
}
]

+ 16
- 3
bubble-server/src/test/resources/models/tests/live/backup_and_restore.json 查看文件

@@ -150,18 +150,25 @@
"response": {
"store": "restoreNN",
"check": [
{"condition": "restoreNN.getNetwork() == bubbleNetwork.getNetwork()"}
{ "condition": "restoreNN.getNetwork() == bubbleNetwork.getNetwork()" },
{ "condition": "restoreNN.getState().name() == 'starting'" }
]
}
},

{
"comment": "restore node using restoreKey",
"before": "await_url .bubble 16m:20m 20s",
"comment": "wait for network and then check its status - should be running",
"connection": {
"name": "restoredBubbleConnection",
"baseUri": "https://{{restoreNN.fqdn}}:{{serverConfig.nginxPort}}/api"
},
"before": "await_url .bubble 16m:20m 20s",
"request": { "uri": "me/networks/{{ restoreNN.getNetwork() }}" },
"response": { "check": [{ "condition": "json.getState().name() == 'restoring'" }] }
},

{
"comment": "restore node using restoreKey",
"request": {
"uri": "auth/restore/{{restoreNN.restoreKey}}",
"entity": {
@@ -190,6 +197,12 @@
}
},

{
"comment": "check again for bubble's status - should be running",
"request": { "uri": "me/networks/{{ restoreNN.getNetwork() }}" },
"response": { "check": [{ "condition": "json.getState().name() == 'running'" }] }
},

{
"comment": "verify account we added has been restored",
"request": {


Loading…
取消
儲存