This commit is contained in:
2026-06-10 06:18:45 +03:00
parent 4089ca40c9
commit 9ec86282ad
47 changed files with 3493 additions and 4502 deletions

View File

@@ -82,7 +82,7 @@ const mainUsage = `Usage:
`
const helpMessage = `Diploma project. Database. Version: 1.0
const helpMessage = `Gordenko project. Database. Version: 1.0
created by Dmytro Gordenko, 1.e4.kc6@gmail.com
`

View File

@@ -7,7 +7,7 @@ import (
"os"
"time"
diploma "gordenko.dev/dima/qb"
"gordenko.dev/dima/qb"
"gordenko.dev/dima/qb/client"
"gordenko.dev/dima/qb/proto"
)
@@ -15,12 +15,12 @@ import (
// METRICS INFO
type MetricInfo struct {
MetricID uint32 `json:"metricID"`
MetricType diploma.MetricType `json:"metricType"`
FracDigits int `json:"fracDigits"`
Since int64 `json:"since"`
Until int64 `json:"until"`
Qty int `json:"qty"`
MetricID uint32 `json:"metricID"`
MetricType qb.MetricType `json:"metricType"`
FracDigits int `json:"fracDigits"`
Since int64 `json:"since"`
Until int64 `json:"until"`
Qty int `json:"qty"`
}
func readMetricInfo(fileName string) (list []MetricInfo, err error) {
@@ -42,12 +42,12 @@ type QueryRecipe struct {
RangeCode int
Since uint32
Until uint32
GroupBy diploma.GroupBy
GroupBy qb.GroupBy
}
type RandomQueryGenerator struct {
metrics []MetricInfo
groupByOptions []diploma.GroupBy
groupByOptions []qb.GroupBy
listCurrentValuesProbability int
listPeriodsProbability int
timeRangeProbDistribution []int
@@ -86,10 +86,10 @@ func NewRandomQueryGenerator(opt RandomQueryGeneratorOptions) *RandomQueryGenera
return &RandomQueryGenerator{
metrics: opt.Metrics,
groupByOptions: []diploma.GroupBy{
diploma.GroupByHour,
diploma.GroupByDay,
diploma.GroupByMonth,
groupByOptions: []qb.GroupBy{
qb.GroupByHour,
qb.GroupByDay,
qb.GroupByMonth,
},
listCurrentValuesProbability: opt.ListCurrentValuesProbability,
listPeriodsProbability: opt.ListPeriodsProbability,
@@ -108,7 +108,7 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
Method: listCurrentValues,
}
} else {
if metric.MetricType == diploma.Cumulative {
if metric.MetricType == qb.Cumulative {
num = rand.Intn(100)
if num < s.listPeriodsProbability {
groupBy := s.groupByOptions[rand.Intn(len(s.groupByOptions))]
@@ -118,10 +118,10 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
maxDays = 7
)
if groupBy == diploma.GroupByDay {
if groupBy == qb.GroupByDay {
minDays = 1
maxDays = 30
} else if groupBy == diploma.GroupByMonth {
} else if groupBy == qb.GroupByMonth {
minDays = 1
maxDays = 30
}
@@ -164,10 +164,10 @@ func (s *RandomQueryGenerator) GetQueryRecipe() QueryRecipe {
maxDays = 7
)
if groupBy == diploma.GroupByDay {
if groupBy == qb.GroupByDay {
minDays = 1
maxDays = 30
} else if groupBy == diploma.GroupByMonth {
} else if groupBy == qb.GroupByMonth {
minDays = 1
maxDays = 30
}
@@ -350,7 +350,7 @@ func execQuery(conn *client.Connection, queryGenerator *RandomQueryGenerator, st
Day: until.Day(),
},
GroupBy: recipe.GroupBy,
AggregateFuncs: diploma.AggregateMin | diploma.AggregateMax | diploma.AggregateAvg,
AggregateFuncs: qb.AggregateMin | qb.AggregateMax | qb.AggregateAvg,
})
elapsedTime = time.Since(t1)
stat.ElapsedTime += elapsedTime

View File

@@ -203,7 +203,7 @@ const mainUsage = `Usage:
`
const helpMessage = `Diploma project. Load test. Version: 1.0
const helpMessage = `Gordenko project. Load test. Version: 1.0
created by Dmytro Gordenko, 1.e4.kc6@gmail.com
`

View File

@@ -54,7 +54,7 @@ const mainUsage = `Usage:
`
const helpMessage = `Diploma project. Example requests. Version: 1.0
const helpMessage = `Gordenko project. Example requests. Version: 1.0
created by Dmytro Gordenko, 1.e4.kc6@gmail.com
`

View File

@@ -5,7 +5,7 @@ import (
"log"
"time"
diploma "gordenko.dev/dima/qb"
"gordenko.dev/dima/qb"
"gordenko.dev/dima/qb/client"
"gordenko.dev/dima/qb/proto"
)
@@ -25,7 +25,7 @@ func sendRequests(conn *client.Connection) {
err = conn.AddMetric(proto.AddMetricReq{
MetricID: instantMetricID,
MetricType: diploma.Instant,
MetricType: qb.Instant,
FracDigits: fracDigits,
})
if err != nil {
@@ -114,8 +114,8 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByHour,
AggregateFuncs: diploma.AggregateMin | diploma.AggregateMax | diploma.AggregateAvg,
GroupBy: qb.GroupByHour,
AggregateFuncs: qb.AggregateMin | qb.AggregateMax | qb.AggregateAvg,
})
if err != nil {
log.Fatalf("conn.ListInstantPeriods: %s\n", err)
@@ -143,8 +143,8 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByDay,
AggregateFuncs: diploma.AggregateMin | diploma.AggregateMax | diploma.AggregateAvg,
GroupBy: qb.GroupByDay,
AggregateFuncs: qb.AggregateMin | qb.AggregateMax | qb.AggregateAvg,
})
if err != nil {
log.Fatalf("conn.ListInstantPeriods: %s\n", err)
@@ -172,8 +172,8 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByMonth,
AggregateFuncs: diploma.AggregateMin | diploma.AggregateMax | diploma.AggregateAvg,
GroupBy: qb.GroupByMonth,
AggregateFuncs: qb.AggregateMin | qb.AggregateMax | qb.AggregateAvg,
})
if err != nil {
log.Fatalf("conn.ListInstantPeriods: %s\n", err)
@@ -208,7 +208,7 @@ GetMetric:
err = conn.AddMetric(proto.AddMetricReq{
MetricID: cumulativeMetricID,
MetricType: diploma.Cumulative,
MetricType: qb.Cumulative,
FracDigits: fracDigits,
})
if err != nil {
@@ -298,7 +298,7 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByHour,
GroupBy: qb.GroupByHour,
})
if err != nil {
log.Fatalf("conn.ListCumulativePeriods: %s\n", err)
@@ -326,7 +326,7 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByDay,
GroupBy: qb.GroupByDay,
})
if err != nil {
log.Fatalf("conn.ListCumulativePeriods: %s\n", err)
@@ -354,7 +354,7 @@ GetMetric:
Month: until.Month(),
Day: until.Day(),
},
GroupBy: diploma.GroupByMonth,
GroupBy: qb.GroupByMonth,
})
if err != nil {
log.Fatalf("conn.ListCumulativePeriods: %s\n", err)