45 lines
1,001 B
Go
45 lines
1,001 B
Go
package database
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/debian/deb-orchestrator/internal/models"
|
|
)
|
|
|
|
// BenchmarkTaskCreation benchmarks task creation performance
|
|
func BenchmarkTaskCreation(b *testing.B) {
|
|
service := NewMockService()
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
taskReq := models.TaskRequest{
|
|
Method: "build",
|
|
Args: []string{"package1"},
|
|
Priority: 1,
|
|
Arch: "amd64",
|
|
Channel: "stable",
|
|
}
|
|
task := models.NewTask(taskReq)
|
|
service.CreateTask(task)
|
|
}
|
|
}
|
|
|
|
// BenchmarkHostCreation benchmarks host creation performance
|
|
func BenchmarkHostCreation(b *testing.B) {
|
|
service := NewMockService()
|
|
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
hostReq := models.HostRequest{
|
|
Name: "benchmark-host",
|
|
Arch: "amd64",
|
|
Channel: "stable",
|
|
Capacity: 10,
|
|
Hostname: "192.168.1.100",
|
|
Port: 22,
|
|
Capabilities: map[string]interface{}{"build": true},
|
|
}
|
|
host := models.NewHost(hostReq)
|
|
service.CreateHost(host)
|
|
}
|
|
}
|