Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Add TestAppHubLogLabels to test AppHub integration from Ops Agent collected logs. #1904

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
42 changes: 35 additions & 7 deletions integration_test/agents/agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,15 +934,43 @@ func CommonSetupWithExtraCreateArgumentsAndMetadata(t *testing.T, imageSpec stri
return ctx, logger, vm
}

// ManagedInstanceGroupVMSetup sets up a Managed Instance Group VM for testing with extra creation arguments for the `gcloud compute instances create` command and additional metadata.
func ManagedInstanceGroupVMSetup(t *testing.T, imageSpec string, extraCreateArguments []string, additionalMetadata map[string]string) (context.Context, *logging.DirectoryLogger, *gce.ManagedInstanceGroupVM) {
t.Helper()
ctx, cancel := context.WithTimeout(context.Background(), gce.SuggestedTimeout)
t.Cleanup(cancel)
gcloudConfigDir := t.TempDir()
if err := gce.SetupGcloudConfigDir(ctx, gcloudConfigDir); err != nil {
t.Fatalf("Unable to set up a gcloud config directory: %v", err)
}
ctx = gce.WithGcloudConfigDir(ctx, gcloudConfigDir)

logger := gce.SetupLogger(t)
logger.ToMainLog().Println("Calling SetupManagedInstanceGroupVM(). For details, see VM_initialization.txt.")
options := gce.VMOptions{
ImageSpec: imageSpec,
TimeToLive: "3h",
MachineType: RecommendedMachineType(imageSpec),
ExtraCreateArguments: extraCreateArguments,
Metadata: additionalMetadata,
}
migVM := gce.SetupManagedInstanceGroupVM(ctx, t, logger.ToFile("VM_initialization.txt"), options)
logger.ToMainLog().Printf("VM is ready: %#v", migVM.VM)
t.Cleanup(func() {
RunOpsAgentDiagnostics(ctx, logger, migVM.VM)
})
return ctx, logger, migVM
}

func InstallOpsAgentUAPPlugin(ctx context.Context, logger *log.Logger, vm *gce.VM, location PackageLocation) error {
// Used for manual testing or pre-submits
if location.packagesInGCS != "" {
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, location.packagesInGCS)
}
// Used for manual testing or pre-submits
if location.packagesInGCS != "" {
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, location.packagesInGCS)
}

// Used for nightly builds
artifactBucket := fmt.Sprintf("gs://%s-ops-agent-releases/%s", location.artifactRegistryProject, location.repoSuffix)
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, artifactBucket)
// Used for nightly builds
artifactBucket := fmt.Sprintf("gs://%s-ops-agent-releases/%s", location.artifactRegistryProject, location.repoSuffix)
return InstallOpsAgentUAPPluginFromGCS(ctx, logger, vm, artifactBucket)
}

// InstallOpsAgentUAPPluginFromGCS installs the Ops Agent plugin tarball from GCS onto the given Linux VM.
Expand Down
Loading