Skip to content

Commit 2a34959

Browse files
committed
orchestration e2e tests to verify start after stop.
Bug: b/523382761
1 parent d0156f3 commit 2a34959

2 files changed

Lines changed: 152 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (C) 2026 The Android Open Source Project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@rules_go//go:def.bzl", "go_test")
16+
17+
go_test(
18+
name = "stop_start_test_test",
19+
srcs = ["main_test.go"],
20+
deps = [
21+
"//orchestration/common",
22+
"@com_github_google_android_cuttlefish_frontend//src/host_orchestrator/api/v1:api",
23+
"@com_github_google_android_cuttlefish_frontend//src/libhoclient:libhoclient",
24+
"@com_github_google_go_cmp//cmp",
25+
],
26+
)
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Copyright (C) 2026 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"encoding/json"
19+
"log"
20+
"testing"
21+
22+
"github.com/google/android-cuttlefish/e2etests/orchestration/common"
23+
24+
hoapi "github.com/google/android-cuttlefish/frontend/src/host_orchestrator/api/v1"
25+
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
26+
"github.com/google/go-cmp/cmp"
27+
)
28+
29+
const baseURL = "http://0.0.0.0:2080"
30+
31+
func TestStopStart(t *testing.T) {
32+
srv := hoclient.NewHostOrchestratorClient(baseURL)
33+
t.Cleanup(func() {
34+
if err := common.CollectHOLogs(baseURL); err != nil {
35+
log.Printf("failed to collect HO logs: %s", err)
36+
}
37+
})
38+
config := `
39+
{
40+
"instances": [
41+
{
42+
"vm": {
43+
"crosvm": {
44+
"enable_sandbox": false
45+
},
46+
"memory_mb": 8192,
47+
"setupwizard_mode": "OPTIONAL",
48+
"cpus": 8
49+
},
50+
"disk": {
51+
"default_build": "@ab/aosp-android-latest-release/aosp_cf_x86_64_only_phone-userdebug",
52+
"download_img_zip": true
53+
},
54+
"streaming": {
55+
"device_id": "cvd-1"
56+
}
57+
},
58+
{
59+
"vm": {
60+
"crosvm": {
61+
"enable_sandbox": false
62+
},
63+
"memory_mb": 8192,
64+
"setupwizard_mode": "OPTIONAL",
65+
"cpus": 8
66+
},
67+
"disk": {
68+
"default_build": "@ab/aosp-android-latest-release/aosp_cf_x86_64_only_phone-userdebug",
69+
"download_img_zip": true
70+
},
71+
"streaming": {
72+
"device_id": "cvd-1"
73+
}
74+
}
75+
]
76+
}
77+
`
78+
envConfig := make(map[string]interface{})
79+
if err := json.Unmarshal([]byte(config), &envConfig); err != nil {
80+
t.Fatal(err)
81+
}
82+
createReq := &hoapi.CreateCVDRequest{
83+
EnvConfig: envConfig,
84+
}
85+
if _, err := srv.CreateCVD(createReq, &hoclient.AccessTokenBuildAPICreds{}); err != nil {
86+
t.Fatal(err)
87+
}
88+
cvds, err := srv.ListCVDs()
89+
if err != nil {
90+
t.Fatal(err)
91+
}
92+
if diff := cmp.Diff(cvdStatus(cvds), []string{"Running", "Running"}); diff != "" {
93+
t.Fatalf("status mismatch (-want +got):\n%s", diff)
94+
}
95+
96+
if err := srv.StopGroup("cvd_1"); err != nil {
97+
t.Fatal(err)
98+
}
99+
cvds, err = srv.ListCVDs()
100+
if err != nil {
101+
t.Fatal(err)
102+
}
103+
if diff := cmp.Diff(cvdStatus(cvds), []string{"Stopped", "Stopped"}); diff != "" {
104+
t.Fatalf("status mismatch (-want +got):\n%s", diff)
105+
}
106+
107+
// TODO(b/523379344): Failing to boot.
108+
// if err := srv.StartGroup("cvd_1", &hoapi.StartCVDRequest{}); err != nil {
109+
// t.Fatal(err)
110+
// }
111+
// cvds, err = srv.ListCVDs()
112+
// if err != nil {
113+
// t.Fatal(err)
114+
// }
115+
// if diff := cmp.Diff(cvdStatus(cvds), []string{"Running", "Running"}); diff != "" {
116+
// t.Fatalf("status mismatch (-want +got):\n%s", diff)
117+
// }
118+
}
119+
120+
func cvdStatus(cvds []*hoapi.CVD) []string {
121+
res := make([]string, len(cvds))
122+
for i, v := range cvds {
123+
res[i] = v.Status
124+
}
125+
return res
126+
}

0 commit comments

Comments
 (0)