Skip to content

Commit

Permalink
Make e2e orchestration tests depend on libhoclient.
Browse files Browse the repository at this point in the history
  • Loading branch information
ser-io committed Oct 15, 2024
1 parent e1c0748 commit 6d128c0
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 25 deletions.
1 change: 1 addition & 0 deletions e2etests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")

GO_PREFIX = "github.com/google/android-cuttlefish/e2etests"

# gazelle:resolve_regexp go github.com/google/android-cuttlefish/frontend/src/libhoclient/* @libhoclient
gazelle(
name = "gazelle",
external = "external",
Expand Down
5 changes: 5 additions & 0 deletions e2etests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,8 @@ local_repository(
name = "images",
path = "..",
)

local_repository(
name = "libhoclient",
path = "../frontend/src/libhoclient",
)
2 changes: 1 addition & 1 deletion e2etests/orchestration/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ go_library(
"@com_github_docker_docker//api/types/container",
"@com_github_docker_docker//client",
"@com_github_docker_go_connections//nat",
"@com_github_google_cloud_android_orchestration//pkg/client",
"@libhoclient",
],
)
6 changes: 3 additions & 3 deletions e2etests/orchestration/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/docker/docker/api/types/container"
clientpkg "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
orchclient "github.com/google/cloud-android-orchestration/pkg/client"
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
)

type TestContext struct {
Expand Down Expand Up @@ -247,7 +247,7 @@ func Cleanup(ctx *TestContext) {
}
}

func DownloadHostBugReport(srv orchclient.HostOrchestratorService, group string) error {
func DownloadHostBugReport(srv hoclient.HostOrchestratorService, group string) error {
// `TEST_UNDECLARED_OUTPUTS_DIR` env var is defined by bazel
// https://bazel.build/reference/test-encyclopedia#initial-conditions
val, ok := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
Expand All @@ -271,7 +271,7 @@ func DownloadHostBugReport(srv orchclient.HostOrchestratorService, group string)
return nil
}

func UploadAndExtract(srv orchclient.HostOrchestratorService, remoteDir, src string) error {
func UploadAndExtract(srv hoclient.HostOrchestratorService, remoteDir, src string) error {
if err := srv.UploadFile(remoteDir, src); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ go_test(
deps = [
"//orchestration/common",
"@com_github_google_android_cuttlefish_frontend_src_host_orchestrator//api/v1:api",
"@com_github_google_cloud_android_orchestration//pkg/client",
"@com_github_google_go_cmp//cmp",
"@libhoclient",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/google/android-cuttlefish/e2etests/orchestration/common"

hoapi "github.com/google/android-cuttlefish/frontend/src/host_orchestrator/api/v1"
"github.com/google/cloud-android-orchestration/pkg/client"
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
"github.com/google/go-cmp/cmp"
)

Expand All @@ -33,7 +33,7 @@ func TestInstance(t *testing.T) {
t.Cleanup(func() {
common.Cleanup(ctx)
})
srv := client.NewHostOrchestratorService(ctx.ServiceURL)
srv := hoclient.NewHostOrchestratorService(ctx.ServiceURL)
uploadDir, err := srv.CreateUploadDir()
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestInstance(t *testing.T) {
EnvConfig: envConfig,
}

got, createErr := srv.CreateCVD(createReq, client.BuildAPICredential{})
got, createErr := srv.CreateCVD(createReq, hoclient.BuildAPICredential{})

if err := common.DownloadHostBugReport(srv, group_name); err != nil {
t.Errorf("failed creating bugreport: %s\n", err)
Expand Down
1 change: 1 addition & 0 deletions e2etests/orchestration/create_local_image_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ go_test(
"@com_github_google_android_cuttlefish_frontend_src_host_orchestrator//api/v1:api",
"@com_github_google_cloud_android_orchestration//pkg/client",
"@com_github_google_go_cmp//cmp",
"@libhoclient",
],
)
8 changes: 4 additions & 4 deletions e2etests/orchestration/create_local_image_test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/google/android-cuttlefish/e2etests/orchestration/common"

hoapi "github.com/google/android-cuttlefish/frontend/src/host_orchestrator/api/v1"
"github.com/google/cloud-android-orchestration/pkg/client"
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
"github.com/google/go-cmp/cmp"
)

Expand All @@ -39,7 +39,7 @@ func TestInstance(t *testing.T) {
t.Cleanup(func() {
common.Cleanup(ctx)
})
srv := client.NewHostOrchestratorService(ctx.ServiceURL)
srv := hoclient.NewHostOrchestratorService(ctx.ServiceURL)
uploadDir, err := srv.CreateUploadDir()
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestInstance(t *testing.T) {
EnvConfig: envConfig,
}

got, createErr := srv.CreateCVD(createReq, client.BuildAPICredential{})
got, createErr := srv.CreateCVD(createReq, hoclient.BuildAPICredential{})

if err := common.DownloadHostBugReport(srv, group_name); err != nil {
t.Errorf("failed creating bugreport: %s\n", err)
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestInstance(t *testing.T) {
}
}

func uploadImages(srv client.HostOrchestratorService, remoteDir, imgsZipSrc string) error {
func uploadImages(srv hoclient.HostOrchestratorService, remoteDir, imgsZipSrc string) error {
outDir := "/tmp/aosp_cf_x86_64_phone-img-12198634"
if err := runCmd("unzip", "-d", outDir, imgsZipSrc); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions e2etests/orchestration/create_single_instance_test/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def create_single_instance_test(name, build_id, build_target):
"@com_github_google_cloud_android_orchestration//pkg/client",
"@com_github_google_android_cuttlefish_frontend_src_host_orchestrator//api/v1:api",
"@com_github_google_go_cmp//cmp",
"@libhoclient",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/google/android-cuttlefish/e2etests/orchestration/common"

hoapi "github.com/google/android-cuttlefish/frontend/src/host_orchestrator/api/v1"
client "github.com/google/cloud-android-orchestration/pkg/client"
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
"github.com/google/go-cmp/cmp"
)

Expand All @@ -35,7 +35,7 @@ func TestCreateSingleInstance(t *testing.T) {
})
buildID := os.Getenv("BUILD_ID")
buildTarget := os.Getenv("BUILD_TARGET")
srv := client.NewHostOrchestratorService(ctx.ServiceURL)
srv := hoclient.NewHostOrchestratorService(ctx.ServiceURL)
createReq := &hoapi.CreateCVDRequest{
CVD: &hoapi.CVD{
BuildSource: &hoapi.BuildSource{
Expand All @@ -49,7 +49,7 @@ func TestCreateSingleInstance(t *testing.T) {
},
}

got, createErr := srv.CreateCVD(createReq, client.BuildAPICredential{})
got, createErr := srv.CreateCVD(createReq, hoclient.BuildAPICredential{})

if err := common.DownloadHostBugReport(srv, "cvd"); err != nil {
t.Errorf("failed creating bugreport: %s\n", err)
Expand Down
1 change: 1 addition & 0 deletions e2etests/orchestration/snapshot_test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ go_test(
"@com_github_google_android_cuttlefish_frontend_src_host_orchestrator//api/v1:api",
"@com_github_google_cloud_android_orchestration//pkg/client",
"@com_github_google_go_cmp//cmp",
"@libhoclient",
],
)
20 changes: 10 additions & 10 deletions e2etests/orchestration/snapshot_test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/google/android-cuttlefish/e2etests/orchestration/common"

hoapi "github.com/google/android-cuttlefish/frontend/src/host_orchestrator/api/v1"
"github.com/google/cloud-android-orchestration/pkg/client"
hoclient "github.com/google/android-cuttlefish/frontend/src/libhoclient"
"github.com/google/go-cmp/cmp"
)

Expand All @@ -41,7 +41,7 @@ func TestSnapshot(t *testing.T) {
if err != nil {
t.Fatal(err)
}
srv := client.NewHostOrchestratorService(ctx.ServiceURL)
srv := hoclient.NewHostOrchestratorService(ctx.ServiceURL)
uploadDir, err := uploadArtifacts(srv)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestSnapshot(t *testing.T) {
}
}

func uploadArtifacts(srv client.HostOrchestratorService) (string, error) {
func uploadArtifacts(srv hoclient.HostOrchestratorService) (string, error) {
uploadDir, err := srv.CreateUploadDir()
if err != nil {
return "", err
Expand All @@ -123,7 +123,7 @@ func uploadArtifacts(srv client.HostOrchestratorService) (string, error) {
return uploadDir, nil
}

func createDevice(srv client.HostOrchestratorService, group_name, artifactsDir string) (*hoapi.CVD, error) {
func createDevice(srv hoclient.HostOrchestratorService, group_name, artifactsDir string) (*hoapi.CVD, error) {
config := `
{
"common": {
Expand Down Expand Up @@ -152,7 +152,7 @@ func createDevice(srv client.HostOrchestratorService, group_name, artifactsDir s
return nil, err
}
createReq := &hoapi.CreateCVDRequest{EnvConfig: envConfig}
res, createErr := srv.CreateCVD(createReq, client.BuildAPICredential{})
res, createErr := srv.CreateCVD(createReq, hoclient.BuildAPICredential{})
if createErr != nil {
if err := common.DownloadHostBugReport(srv, group_name); err != nil {
log.Printf("error downloading cvd bugreport: %v", err)
Expand All @@ -175,7 +175,7 @@ type StartCVDRequest struct {

// TODO(b/370550070) Remove once this method is added to the client implementation.
func createSnapshot(srvURL, group, name string) (*CreateSnapshotResponse, error) {
helper := client.HTTPHelper{
helper := hoclient.HTTPHelper{
Client: http.DefaultClient,
RootEndpoint: srvURL,
}
Expand All @@ -185,7 +185,7 @@ func createSnapshot(srvURL, group, name string) (*CreateSnapshotResponse, error)
if err := rb.JSONResDo(op); err != nil {
return nil, err
}
srv := client.NewHostOrchestratorService(srvURL)
srv := hoclient.NewHostOrchestratorService(srvURL)
res := &CreateSnapshotResponse{}
if err := srv.WaitForOperation(op.Name, res); err != nil {
return nil, err
Expand All @@ -207,7 +207,7 @@ func startDevice(srvURL, group, name, snapshotID string) error {
}

func doRequest(srvURL, group, name, oper string, body any) error {
helper := client.HTTPHelper{
helper := hoclient.HTTPHelper{
Client: http.DefaultClient,
RootEndpoint: srvURL,
}
Expand All @@ -217,15 +217,15 @@ func doRequest(srvURL, group, name, oper string, body any) error {
if err := rb.JSONResDo(op); err != nil {
return err
}
srv := client.NewHostOrchestratorService(srvURL)
srv := hoclient.NewHostOrchestratorService(srvURL)
res := &hoapi.EmptyResponse{}
if err := srv.WaitForOperation(op.Name, &res); err != nil {
return err
}
return nil
}

func getCVD(srv client.HostOrchestratorService) (*hoapi.CVD, error) {
func getCVD(srv hoclient.HostOrchestratorService) (*hoapi.CVD, error) {
cvds, err := srv.ListCVDs()
if err != nil {
return nil, err
Expand Down

0 comments on commit 6d128c0

Please sign in to comment.