Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
wildum committed Oct 29, 2024
1 parent 01eeb2c commit 2b5d9bb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
11 changes: 11 additions & 0 deletions internal/cmd/integration-tests/docker-compose.windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:

mimir:
image: grafana/mimir:2.10.4
volumes:
- ./configs/mimir:/etc/mimir-config
entrypoint:
- /bin/mimir
- -config.file=/etc/mimir-config/mimir.yaml
ports:
- "9009:9009"
1 change: 0 additions & 1 deletion internal/cmd/integration-tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:

mimir:
Expand Down
21 changes: 12 additions & 9 deletions internal/cmd/integration-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ func runIntegrationTests(cmd *cobra.Command, args []string) {
defer reportResults()
defer cleanUpEnvironment()

if !skipBuild {
buildAlloy()
}

testFolder := "./tests/"
alloyBinaryPath := "../../../../../build/alloy"
alloyBinary := "build/alloy"
dockerComposeFile := "docker-compose.yaml"

if runtime.GOOS != "windows" {
setupEnvironment()
} else {
if runtime.GOOS == "windows" {
testFolder = "./tests-windows/"
//alloyBinaryPath = "..\\..\\..\\..\\..\\build\\alloy"
fmt.Println("Skipping environment setup on Windows.")
alloyBinaryPath = "..\\..\\..\\..\\..\\build\\alloy.exe"
alloyBinary = "build/alloy.exe"
dockerComposeFile = "docker-compose.windows.yaml"
}

if !skipBuild {
buildAlloy(alloyBinary)
}

setupEnvironment(dockerComposeFile)

if specificTest != "" {
fmt.Println("Running", specificTest)
if !filepath.IsAbs(specificTest) && !strings.HasPrefix(specificTest, testFolder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

func TestWindowsMetrics(t *testing.T) {
var winMetrics = []string{
"windows_cpu_logical_processor", // cpu
"windows_cpu_time_total", // cpu
"windows_cs_logical_processors", // cs
"windows_logical_disk_info", // logical_disk
"windows_net_bytes_received_total", // net
"windows_os_info", // os
"windows_service_info", // service
"windows_system_processes", // system
"windows_system_system_up_time", // system
}
common.MimirMetricsTest(t, winMetrics, []string{}, "win_metrics")
}
11 changes: 7 additions & 4 deletions internal/cmd/integration-tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func executeCommand(command string, args []string, taskDescription string) {
}
}

func buildAlloy() {
executeCommand("make", []string{"-C", "../../..", "alloy"}, "Building Alloy")
func buildAlloy(alloyBinary string) {
executeCommand("make", []string{"-C", "../../..", "alloy", fmt.Sprintf("ALLOY_BINARY=%s", alloyBinary)}, "Building Alloy")
}

func setupEnvironment() {
executeCommand("docker", []string{"compose", "up", "-d"}, "Setting up environment with Docker Compose")
func setupEnvironment(dockerComposeFile string) {
executeCommand("docker", []string{"compose", "-f", dockerComposeFile, "up", "-d"}, "Setting up environment with Docker Compose")
fmt.Println("Sleep for 45 seconds to ensure that the env has time to initialize...")
time.Sleep(45 * time.Second)
}
Expand Down Expand Up @@ -84,6 +84,9 @@ func runSingleTest(alloyBinaryPath string, testDir string, port int) {
}
}

// sleep for a few seconds before deleting the files to make sure that they are not use anymore
time.Sleep(5 * time.Second)

err = os.RemoveAll(filepath.Join(testDir, "data-alloy"))
if err != nil {
panic(err)
Expand Down

0 comments on commit 2b5d9bb

Please sign in to comment.