Skip to content

Commit

Permalink
added windows and macos benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
okankoAMZ committed Oct 10, 2023
1 parent 7aaf436 commit e0a4c77
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ jobs:
passphrase: ${{ secrets.PASSPHRASE }}
BinaryBenchmarkTest:
name: BinaryBenchmarkTest
runs-on: ubuntu-latest
needs: [MakeBinary]
needs: [ MakeBinary ]
permissions:
id-token: write
contents: read
strategy:
matrix:
os: [ubuntu-latest,windows-latest,macos-latest]
include:
- os: ubuntu-latest
installationScript: time sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
- os: windows-latest
installationScript: Measure-Command { Start-Process msiexec "/i ./amazon-cloudwatch-agent.msi /norestart " }
- os: macos-latest
installationScript: time sudo installer -pkg ./amazon-cloudwatch-agent.pkg -target /
runs-on: ${{ matrix.os }}
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
Expand All @@ -126,10 +136,14 @@ jobs:
- name: Download RPM
run: |
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/linux/amd64/amazon-cloudwatch-agent.deb .
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/amd64/amazon-cloudwatch-agent.pkg .
aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/${{ inputs.PackageBucketKey }}/amazon-cloudwatch-agent.msi .
- name: GetRPMSize
run: ls -lh
if: matrix.os == 'ubuntu-latest'
run: ls -lh
- name: Measure Installation Time
run : time sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
run : ${{matrix.installationScript}}

# #GH actions set up gpg only works on ubuntu as of this commit date
GPGSignMacAndWindowsPackage:
Expand Down
5 changes: 1 addition & 4 deletions packaging/uniformBuild/aws_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ func StopInstance(c context.Context, api EC2StopInstancesAPI, input *ec2.StopIns
return resp, err
}
func StopInstanceCmd(client *ec2.Client, instanceID string) error {
//@TODO:Change to terminate

input := &ec2.StopInstancesInput{
InstanceIds: []string{
instanceID,
Expand All @@ -292,7 +290,6 @@ func StopInstanceCmd(client *ec2.Client, instanceID string) error {
}

func TerminateInstanceCmd(client *ec2.Client, instanceID string) error {
//@TODO:Change to terminate

input := &ec2.TerminateInstancesInput{
InstanceIds: []string{
Expand All @@ -306,7 +303,7 @@ func TerminateInstanceCmd(client *ec2.Client, instanceID string) error {
fmt.Println("Got an error terminating the instance")
return err
}
fmt.Println("Stopped instance with ID " + instanceID)
fmt.Println("Terminated the instance with ID " + instanceID)
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions packaging/uniformBuild/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const BUILD_ARN = "arn:aws:iam::506463145083:instance-profile/Uniform-Build-Env-
const COMMAND_TRACKING_TIMEOUT = 20 * time.Minute
const COMMAND_TRACKING_INTERVAL = 1 * time.Second
const COMMAND_TRACKING_COUNT = int(COMMAND_TRACKING_TIMEOUT / COMMAND_TRACKING_INTERVAL)
const PLATFORM_KEY = "platform"

const (
LINUX OS = "linux"
Expand All @@ -35,5 +36,3 @@ var SUPPORTED_OS = []OS{
WINDOWS,
MACOS,
} //go doesn't let me create a slice from enum so this is the solution

const PLATFORM_KEY = "platform"
2 changes: 1 addition & 1 deletion packaging/uniformBuild/docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ InstanceManager



0aa349f04d9ea7346


## FAQ
- Q: Why are we running commands as one giant command instead of individual ones?
Expand Down
27 changes: 14 additions & 13 deletions packaging/uniformBuild/uniformBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ func (rbm *RemoteBuildManager) BuildCWAAgent(gitUrl string, branch string, commi

// Windows
func (rbm *RemoteBuildManager) MakeMsiZip(instanceName string, commitHash string) error {
//rbm.fileExistsInS3(fmt.)
//@TODO add cache
//@TODO add os check
err := rbm.instanceManager.insertOSRequirement(instanceName, LINUX)
if err != nil {
return err
}
if isAlreadyBuilt := rbm.fileExistsInS3(fmt.Sprintf("%s/buildMSI.zip", commitHash)); isAlreadyBuilt {
fmt.Println("\033Found cache skipping build")
return nil
}
command := mergeCommands(
CloneGitRepo(TEST_REPO, "main"),
"cd ccwa",
Expand Down Expand Up @@ -181,17 +186,14 @@ func initEnvCmd(os OS) string {
// CACHE COMMANDS
func (rbm *RemoteBuildManager) fileExistsInS3(targetFile string) bool {
fmt.Printf("Checking for %s cache \n", targetFile)
input := &s3.ListObjectsV2Input{
input := &s3.HeadObjectInput{
Bucket: aws.String(S3_INTEGRATION_BUCKET),
Prefix: aws.String(targetFile),
Key: aws.String(targetFile),
}
_, err := rbm.s3Client.ListObjectsV2(context.Background(), input)
_, err := rbm.s3Client.HeadObject(context.TODO(), input)
if err != nil {
if err.Error() == "NotFound: Not Found" {
fmt.Printf("Object %s does not exist in bucket %s\n", S3_INTEGRATION_BUCKET, targetFile)
} else {
fmt.Println(err)
}
fmt.Printf("Object %s does not exist in bucket %s\n", targetFile, S3_INTEGRATION_BUCKET)
fmt.Println(err)
return false
}
fmt.Printf("Object %s exists in bucket %s\n", S3_INTEGRATION_BUCKET, targetFile)
Expand All @@ -200,7 +202,6 @@ func (rbm *RemoteBuildManager) fileExistsInS3(targetFile string) bool {
}

func main() {
//@TODO FIX CACHE
var repo string
var branch string
var comment string
Expand Down Expand Up @@ -246,7 +247,7 @@ func main() {
fmt.Printf("Failed because: %s \n", err)
return
}
fmt.Printf("\033[32mSuccesfully\033[0m built CWA from %s with %s branch, check \033[32m%s \033[0m bucket with \033[1;32m%s\033[0m hash",
fmt.Printf("\033[32mSuccesfully\033[0m built CWA from %s with %s branch, check \033[32m%s \033[0m bucket with \033[1;32m%s\033[0m hash\n",
repo, branch, S3_INTEGRATION_BUCKET, comment)

}
5 changes: 2 additions & 3 deletions packaging/uniformBuild/uniformBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestMain(m *testing.M) {
}
func TestAmiLatest(t *testing.T) {
cfg, _ := config.LoadDefaultConfig(context.TODO())

imng := CreateNewInstanceManager(cfg, DEFAULT_INSTANCE_GUIDE)
// is it consistent
previous := *imng.GetLatestAMIVersion(accountID).ImageId
Expand Down Expand Up @@ -61,8 +60,8 @@ func TestS3Cache(t *testing.T) {
cfg, _ := config.LoadDefaultConfig(context.TODO())
rbm := RemoteBuildManager{}
rbm.s3Client = s3.NewFromConfig(cfg)
require.False(t, rbm.CheckS3("FileThatDoestExist"), "Should fail")
rbm.CheckS3("s3Check")
require.False(t, rbm.fileExistsInS3("FileThatDoestExist"), "Should fail")
require.True(t, rbm.fileExistsInS3("checkS3"))

}
func TestOnSpecificInstance(t *testing.T) {
Expand Down

0 comments on commit e0a4c77

Please sign in to comment.