Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisonB319 committed Feb 15, 2024
1 parent c730493 commit 92d7418
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
24 changes: 3 additions & 21 deletions e2e/scenario/scenario_ubuntu2204-standalone-containerd.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package scenario

import (
"encoding/json"
"os"
"strings"

"github.com/Azure/agentbaker/pkg/agent/datamodel"
)

Expand Down Expand Up @@ -42,31 +38,17 @@ func (t *Template) ubuntu2204ContainerdVersion() *Scenario {
nbc.ContainerdVersion = "1.6.9"
},
LiveVMValidators: []*LiveVMValidator{
containerdVersionValidator(getCurrentManifestContainerdVersion()),
containerdVersionValidator(getContainerdManifestVersion()),
},
},
}
}

type Manifest struct {
Containerd struct {
Edge string `json:"edge"`
} `json:"containerd"`
}

func getCurrentManifestContainerdVersion() string {
manifestData, err := os.ReadFile("../parts/linux/cloud-init/artifacts/manifest.json")
func getContainerdManifestVersion() string {
manifest, err := getVHDManifest()
if err != nil {
return ""
}
manifestDataStr := string(manifestData)
manifestDataStr = strings.TrimRight(manifestDataStr, "#EOF \n\r\t")
manifestData = []byte(manifestDataStr)

var manifest Manifest
err = json.Unmarshal([]byte(manifestData), &manifest)
if err != nil {
return ""
}
return manifest.Containerd.Edge
}
1 change: 1 addition & 0 deletions e2e/scenario/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func containerdVersionValidator(version string) *LiveVMValidator {
if code != "0" {
return fmt.Errorf("validator command terminated with exit code %q but expected code 0", code)
}

if !strings.Contains(stdout, version) {
return fmt.Errorf(fmt.Sprintf("expected to find containerd version %s, but was not", version))
}
Expand Down
22 changes: 22 additions & 0 deletions e2e/scenario/vhd.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,28 @@ func mustGetVHDCatalogFromEmbeddedJSON(rawJSON string) VHDCatalog {
return catalog
}

type Manifest struct {
Containerd struct {
Edge string `json:"edge"`
} `json:"containerd"`
}

func getVHDManifest() (Manifest, error) {
manifestData, err := os.ReadFile("../parts/linux/cloud-init/artifacts/manifest.json")
if err != nil {
return Manifest{}, err
}
manifestDataStr := string(manifestData)
manifestDataStr = strings.TrimRight(manifestDataStr, "#EOF \n\r\t")
manifestData = []byte(manifestDataStr)

manifest := Manifest{}
if err = json.Unmarshal([]byte(manifestData), &manifest); err != nil {
panic(err)
}
return manifest, nil
}

// VHDResourceID represents a resource ID pointing to a VHD in Azure. This could be theoretically
// be the resource ID of a managed image or SIG image version, though for now this will always be a SIG image version.
type VHDResourceID string
Expand Down

0 comments on commit 92d7418

Please sign in to comment.