Skip to content

Commit

Permalink
Int64 fix (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
koln67 authored Sep 22, 2023
1 parent 907340d commit 1685a28
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion imagetest/test_suites/hotattach/hot_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func getProjectAndZone() (string, string, error) {

func getLinuxMountPath(mountDiskSizeGB int, mountDiskName string) (string, error) {
symlinkRealPath := ""
diskPartition, err := utils.GetMountDiskPartition(mountDiskSizeGB * bytesInGB)
diskPartition, err := utils.GetMountDiskPartition(mountDiskSizeGB)
if err == nil {
symlinkRealPath = "/dev/" + diskPartition
} else {
Expand Down
1 change: 0 additions & 1 deletion imagetest/test_suites/hotattach/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const (
diskName = "hotattachMount"
instanceName = "hotattachvm"

bytesInGB = 1073741824
bootDiskSizeGB = 10
mountDiskSizeGB = 30

Expand Down
2 changes: 1 addition & 1 deletion imagetest/test_suites/storageperf/iops_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func RunFIOReadWindows(mode string) ([]byte, error) {

func getLinuxSymlinkRead() (string, error) {
symlinkRealPath := ""
diskPartition, err := utils.GetMountDiskPartition(hyperdiskSizeGB * bytesInGB)
diskPartition, err := utils.GetMountDiskPartition(hyperdiskSizeGB)
if err == nil {
symlinkRealPath = "/dev/" + diskPartition
} else {
Expand Down
2 changes: 1 addition & 1 deletion imagetest/test_suites/storageperf/iops_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func RunFIOWriteWindows(mode string) ([]byte, error) {

func getLinuxSymlinkWrite() (string, error) {
symlinkRealPath := ""
diskPartition, err := utils.GetMountDiskPartition(hyperdiskSizeGB * bytesInGB)
diskPartition, err := utils.GetMountDiskPartition(hyperdiskSizeGB)
if err == nil {
symlinkRealPath = "/dev/" + diskPartition
} else {
Expand Down
2 changes: 0 additions & 2 deletions imagetest/test_suites/storageperf/storage_perf_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const (
vmName = "vm"
// iopsErrorMargin allows for a small difference between iops found in the test and the iops value listed in public documentation.
iopsErrorMargin = 0.95
// hyperdiskSize in bytes is used to determine which partition is the mounted hyperdisk.
bytesInGB = 1073741824
hyperdiskSizeGB = 3500
bootdiskSizeGB = 50
mountDiskName = "hyperdisk"
Expand Down
12 changes: 8 additions & 4 deletions imagetest/utils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import (
"golang.org/x/crypto/ssh"
)

const metadataURLPrefix = "http://metadata.google.internal/computeMetadata/v1/instance/"
const (
metadataURLPrefix = "http://metadata.google.internal/computeMetadata/v1/instance/"
bytesInGB = 1073741824
)

var windowsClientImagePatterns = []string{
"windows-7-",
Expand All @@ -40,7 +43,7 @@ type BlockDeviceList struct {
// BlockDevice defines information about a single partition or disk in the output of lsblk.
type BlockDevice struct {
Name string `json:"name,omitempty"`
Size int `json:"size,omitempty"`
Size int64 `json:"size,omitempty"`
Type string `json:"type,omitempty"`
// Other fields are not currently used.
X map[string]interface{} `json:"-"`
Expand Down Expand Up @@ -399,7 +402,8 @@ func FailOnPowershellFail(command string, errorMsg string, t *testing.T) {

// GetMountDiskPartition runs lsblk to get the partition of the mount disk on linux, assuming the
// size of the mount disk is diskExpectedSizeGb.
func GetMountDiskPartition(diskExpectedSizeBytes int) (string, error) {
func GetMountDiskPartition(diskExpectedSizeGB int) (string, error) {
var diskExpectedSizeBytes int64 = int64(diskExpectedSizeGB) * int64(bytesInGB)
lsblkCmd := "lsblk"
if !CheckLinuxCmdExists(lsblkCmd) {
return "", fmt.Errorf("could not find lsblk")
Expand All @@ -422,7 +426,7 @@ func GetMountDiskPartition(diskExpectedSizeBytes int) (string, error) {
}
// we should have a slice of length 3, with fields name, size, type
var blkname, blksize, blktype = linetokens[0], linetokens[1], linetokens[2]
blksizeInt, err := strconv.Atoi(blksize)
blksizeInt, err := strconv.ParseInt(blksize, 10, 64)
if err != nil {
return "", fmt.Errorf("did not find int in output of lsblk: string %s error %v", blksize, err)
}
Expand Down

0 comments on commit 1685a28

Please sign in to comment.