Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,51 @@ jobs:
# Run create_from_images_zip_test e2e tests
cd e2etests
bazel test orchestration/create_from_images_zip_test:create_from_images_zip_test_test
e2etests-podcvd:
runs-on: ubuntu-24.04-8core
needs: [build-debian-package-amd64, build-docker-image-amd64]
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # aka v1.3.1
with:
docker-images: false
swap-storage: false
tool-cache: true
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Download cuttlefish debs
uses: actions/download-artifact@v7
with:
name: debs_amd64
- name: Install cuttlefish-podcvd
run: |
tar -xvf debs_amd64.tar
sudo apt install -y ./cuttlefish-podcvd_*.deb
/usr/lib/cuttlefish-common/bin/cuttlefish-podcvd-prerequisites.sh
- name: Download docker image
uses: actions/download-artifact@v7
with:
name: cuttlefish-orchestration-amd64
- name: Load docker image as podman image
run: |
sudo sysctl -w kernel.unprivileged_userns_clone=1
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
sudo apt install -y skopeo
skopeo copy \
docker-archive:cuttlefish-orchestration.tar \
containers-storage:localhost/cuttlefish-orchestration:latest
- name: Run cvd e2e test for podcvd
run: |
cd e2etests
sg kvm -c "bazel test //cvd/... \
--test_env=HOME=$HOME \
--test_env=USE_PODCVD=true \
--test_env=XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
--test_output=errors \
-- \
-//cvd/bugreport_tests/... \
-//cvd/cvd_load_tests/... \
-//cvd/graphics_detector_tests/... \
-//cvd/graphics_tests/... \
-//cvd/launch_cvd_tests/... \
-//cvd/metrics_tests/..."
2 changes: 1 addition & 1 deletion container/src/podcvd/internal/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package internal

// TODO(seungjaeyoo): Propagate these constant values from the debian package wrapping podcvd.
const (
imageName = "us-docker.pkg.dev/android-cuttlefish-artifacts/cuttlefish-orchestration/cuttlefish-orchestration:nightly"
imageName = "localhost/cuttlefish-orchestration:latest"
portOperatorHttps = 1443
ifName = "podcvd"
)
Expand Down
2 changes: 1 addition & 1 deletion e2etests/cvd/bugreport_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestTakeBugreport(t *testing.T) {
t.Fatal(err)
}

if _, err := c.RunCmd("cvd", "host_bugreport"); err != nil {
if _, err := c.RunCmd(c.TargetBin(), "host_bugreport"); err != nil {
t.Fatal(err)
}
}
24 changes: 18 additions & 6 deletions e2etests/cvd/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ type TestContext struct {

context context.Context
cancelled bool

usePodcvd bool
}

func runCmdWithContextEnv(ctx context.Context, command []string, envvars map[string]string) (string, error) {
Expand Down Expand Up @@ -127,6 +129,14 @@ func (tc *TestContext) RunCmd(args... string) (string, error) {
return tc.RunCmdWithEnv(command, map[string]string{})
}

// Returns the binary name to test.
func (tc *TestContext) TargetBin() string {
if tc.usePodcvd {
return "podcvd"
}
return "cvd"
}

// Common parameters passed to `cvd fetch`.
type FetchArgs struct {
DefaultBuildBranch string
Expand All @@ -150,7 +160,7 @@ type FetchAndCreateArgs struct {
func (tc *TestContext) CVDFetch(args FetchArgs) error {
log.Printf("Fetching...")
fetchCmd := []string{
"cvd",
tc.TargetBin(),
"fetch",
fmt.Sprintf("--default_build=%s/%s", args.DefaultBuildBranch, args.DefaultBuildTarget),
fmt.Sprintf("--target_directory=%s", tc.tempdir),
Expand Down Expand Up @@ -185,7 +195,8 @@ func (tc *TestContext) CVDCreate(args CreateArgs) error {
"HOME": tc.tempdir,
}

createCmd := []string{"cvd", "create"};
createCmd := []string{tc.TargetBin(), "--verbosity=DEBUG", "create"};
createCmd = append(createCmd, "--vhost_user_vsock=true")
createCmd = append(createCmd, "--report_anonymous_usage_stats=y")
createCmd = append(createCmd, "--undefok=report_anonymous_usage_stats")
if len(args.Args) > 0 {
Expand All @@ -206,7 +217,7 @@ func (tc *TestContext) CVDStop() error {
"HOME": tc.tempdir,
}

stopCmd := []string{"cvd", "stop"};
stopCmd := []string{tc.TargetBin(), "stop"};
if _, err := tc.RunCmdWithEnv(stopCmd, tempdirEnv); err != nil {
log.Printf("Failed to stop instance(s): %w", err)
return err
Expand Down Expand Up @@ -271,7 +282,7 @@ func (tc *TestContext) CVDLoad(load LoadArgs) error {

log.Printf("Creating instance(s) via `cvd load`...")
loadCmd := []string{
"cvd",
tc.TargetBin(),
"load",
configpath,
};
Expand All @@ -295,11 +306,12 @@ func (tc *TestContext) SetUp(t *testing.T) {
tc.teardownCalled = false
cancellableContext, cancel := context.WithCancel(t.Context())
tc.context = cancellableContext
tc.usePodcvd = os.Getenv("USE_PODCVD") == "true"

log.Printf("Initializing %s test...", tc.t.Name())

log.Printf("Cleaning up any pre-existing instances...")
if _, err := tc.RunCmd("cvd", "reset", "-y"); err != nil {
if _, err := tc.RunCmd(tc.TargetBin(), "reset", "-y"); err != nil {
log.Printf("Failed to cleanup any pre-existing instances: %w", err)
}
log.Printf("Finished cleaning up any pre-existing instances!")
Expand Down Expand Up @@ -414,7 +426,7 @@ func (tc *TestContext) TearDown() {
}
}

runCmdWithContextEnv(context.TODO(), []string{"cvd", "reset", "-y"}, map[string]string{})
runCmdWithContextEnv(context.TODO(), []string{tc.TargetBin(), "reset", "-y"}, map[string]string{})

log.Printf("Finished cleaning up after test!")
}
Expand Down
4 changes: 2 additions & 2 deletions e2etests/cvd/display_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func addDisplay(c e2etests.TestContext, t *testing.T) {
t.Fatal(err)
}

if _, err := c.RunCmd("cvd", "display", "add", "--display=width=500,height=500",); err != nil {
if _, err := c.RunCmd(c.TargetBin(), "display", "add", "--display=width=500,height=500",); err != nil {
t.Fatal(err)
}
}
Expand All @@ -55,7 +55,7 @@ func listDisplays(c e2etests.TestContext, t *testing.T) {
t.Fatal(err)
}

if _, err := c.RunCmd("cvd", "display", "list",); err != nil {
if _, err := c.RunCmd(c.TargetBin(), "display", "list",); err != nil {
t.Fatal(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2etests/cvd/env_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestListEnvServices(t *testing.T) {
t.Fatal(err)
}

if _, err := c.RunCmd("cvd", "env", "ls",); err != nil {
if _, err := c.RunCmd(c.TargetBin(), "env", "ls",); err != nil {
t.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion e2etests/cvd/metrics_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestMetrics(t *testing.T) {

var metricsdir string
err := func() error {
output, err := c.RunCmd("cvd", "fleet")
output, err := c.RunCmd(c.TargetBin(), "fleet")
if err != nil {
return fmt.Errorf("failed to run `cvd fleet`")
}
Expand Down
Loading