Skip to content

Commit

Permalink
Update appnetctl verify & add wrk installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Romero027 committed May 23, 2024
1 parent 4f47661 commit d3bb7c0
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 16 deletions.
68 changes: 52 additions & 16 deletions appnetctl/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"fmt"
"os/exec"
"regexp"
"strconv"
"strings"

Expand All @@ -26,12 +27,7 @@ func execCommand(command string, args ...string) (string, error) {
}

func isVersionGreaterThan(version string, major, minor int) (bool, error) {
// Split version string on spaces (e.g., "Python 3.9.1") and then on dots
parts := strings.Split(version, " ")
if len(parts) < 2 {
return false, fmt.Errorf("unexpected version format")
}
versionParts := strings.Split(parts[1], ".")
versionParts := strings.Split(version, ".")
if len(versionParts) < 2 {
return false, fmt.Errorf("unexpected version format")
}
Expand Down Expand Up @@ -66,13 +62,19 @@ var verifyCmd = &cobra.Command{
// Check if Python version is greater than 3.10
pythonVersion, err := execCommand("python", "--version")
if err == nil {
isGreater, err := isVersionGreaterThan(pythonVersion, 3, 10)
// Parse Python Version
parts := strings.Split(pythonVersion, " ")
if len(parts) < 2 {
fmt.Println("unexpected Python version format")
}

isGreater, err := isVersionGreaterThan(parts[1], 3, 10)
if err != nil {
fmt.Printf("✘ Failed to parse Python version: %s\n", err)
} else if isGreater {
fmt.Printf("✔ Python installed.\n")
fmt.Println("✔ Python installed.")
} else {
fmt.Printf("✘ Python version is not greater than 3.10: %s\n", pythonVersion)
fmt.Printf("✘ Python version is not greater than 3.10: %s", pythonVersion)
}
} else {
fmt.Println("✘ Python is not installed.")
Expand All @@ -81,33 +83,67 @@ var verifyCmd = &cobra.Command{
// Verify Rust installation
_, err = execCommand("rustc", "--version")
if err == nil {
fmt.Printf("✔ Rust installed.\n")
fmt.Println("✔ Rust installed.")
} else {
fmt.Println("✘ Rust is not installed.")
}

// Verify Kubernetes installation
_, err = execCommand("kubectl", "version")
kubectlVersion, err := execCommand("kubectl", "version")
if err == nil {
fmt.Printf("✔ Kubernetes installed.\n")
// Parse kubectl Version
re := regexp.MustCompile(`Client Version: v(\d+\.\d+\.\d+)`)

// Find the version number in the output
matches := re.FindStringSubmatch(kubectlVersion)
if len(matches) < 2 {
fmt.Println("Version number not found")
return
}

isGreater, err := isVersionGreaterThan(matches[1], 1, 28)
if err != nil {
fmt.Printf("✘ Failed to parse kubectl version: %s\n", err)
} else if isGreater {
fmt.Println("✔ Kubernetes installed.")
} else {
fmt.Printf("✘ Kubernetes version is not greater than 1.28.0: %s", pythonVersion)
}
} else {
fmt.Println("✘ Kubernetes is not installed.")
}

// Verify protoc installation
_, err = execCommand("protoc", "--version")
if err == nil {
fmt.Printf("✔ protoc installed.\n")
fmt.Println("✔ protoc installed.")
} else {
fmt.Println("✘ protoc is not installed.")
}

// Verify istio installation
_, err = execCommand("istioctl", "version")
istioctlVersion, err := execCommand("istioctl", "version")
if err == nil {
fmt.Printf("✔ istio installed.\n")
// Parse istioctl Version
re := regexp.MustCompile(`client version: (\d+\.\d+\.\d+)`)

// Find the version number in the output
matches := re.FindStringSubmatch(istioctlVersion)
if len(matches) < 2 {
fmt.Println("Version number not found")
return
}

isGreater, err := isVersionGreaterThan(matches[1], 1, 22)
if err != nil {
fmt.Printf("✘ Failed to parse istioctl version: %s\n", err)
} else if isGreater {
fmt.Println("✔ Istio installed.")
} else {
fmt.Printf("✘ Istio version is not greater than 1.22.0: %s", pythonVersion)
}
} else {
fmt.Println("✘ istio is not installed.")
fmt.Println("✘ Istio is not installed.")
}
},
}
Expand Down
24 changes: 24 additions & 0 deletions utils/perf_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -ex

# Install wrk and wrk2
sudo apt-get install luarocks -y
sudo luarocks install luasocket

git clone https://github.com/wg/wrk.git
pushd wrk
make -j $(nproc)

popd

sudo apt-get install libssl-dev -y
sudo apt-get install libz-dev -y

git clone https://github.com/giltene/wrk2.git
pushd wrk2
make -j $(nproc)

popd

set +ex

0 comments on commit d3bb7c0

Please sign in to comment.