Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #64

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.12.x
- 1.13.x
- tip

go_import_path: github.com/v3io/http_blaster
Expand Down
29 changes: 16 additions & 13 deletions examples/faker_2_kv_example.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
title = "Workload example"

[global]
Duration = "160s"
server="webapi.default-tenant.app.hostname.lab.iguazeng.com"
port="8081"
TLSMode=false
Duration="3600s"
servers=["Servers"]
port="8444"
TLSMode=true
[global.StatusCodesAcceptance]
200 = 100.0 # upto 100% return status of 200
204 = 100.0
205 = 100.0

[workloads]
[workloads.load_faker_to_kv]
name="faker_to_kv"
count=1
[workloads.fakertokv]
name="load_faker_to_kv"
Generator="faker2kv"
container="bigdata"
lazy=10
Target="faker2kv/"
workers=100
container="parquez"
count=10000000000000000
duration="72h"
lazy = 100
type="PUT"
workers=1
Target="faker/"
Partition="day"
[workloads.load_faker_to_kv.Header]
"Authorization"="Basic abcdefg"
[workloads.fakertokv.Header]
"Authorization"="Authorization"

52 changes: 26 additions & 26 deletions httpblaster/data_generator/memoryGenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package data_generator
import (
"encoding/json"
"fmt"
log "github.com/sirupsen/logrus"
"strings"

//"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/mem"
"github.com/v3io/http_blaster/httpblaster/igz_data"
Expand All @@ -14,55 +14,55 @@ import (
"time"
)

type MemoryGenerator struct{
Total uint64
Availible uint64
Active uint64
type MemoryGenerator struct {
Total uint64
Availible uint64
Active uint64
}

func (self *MemoryGenerator) GenerateRandomData(cpuNumber string) []string{
func (self *MemoryGenerator) GenerateRandomData(cpuNumber string) []string {
//stats, _ := cpu.Info()
//fmt.Println(stats)
v, _ := mem.VirtualMemory()
payloads :=self.GenerateJsonArray(v ,cpuNumber)
fmt.Println(strings.Join(payloads, ", "))
payloads := self.GenerateJsonArray(v, cpuNumber)
log.Debugln("[" + strings.Join(payloads, ", ") + "]")
//fmt.Println(strings.Join(payloads, ", "))
return payloads
}

func (self *MemoryGenerator) GenerateJsonByVal(timestamp string,colName string,val float64 , cpuNumber string) string{
func (self *MemoryGenerator) GenerateJsonByVal(timestamp string, colName string, val float64, cpuNumber string) string {
//item :=igz_data.IgzTSDBItem{}
item :=igz_data.IgzTSDBItem{}
item := igz_data.IgzTSDBItem{}
item.InsertMetric("memory")
item.InsertLable("type",colName)
item.InsertLable("hostname",GetHostname())
item.InsertLable("cpu",string(cpuNumber))
item.InsertLable("type", colName)
item.InsertLable("hostname", GetHostname())
item.InsertLable("cpu", string(cpuNumber))

item.InsertSample(timestamp,val)
item.InsertSample(timestamp, val)
return item.ToJsonString()
}


func (self *MemoryGenerator) GenerateJsonArray(v *mem.VirtualMemoryStat,cpuNumber string) []string{
timestamp := NowAsUnixMilli()
arr := []string{}
val := make(map[string]interface{})
if err := json.Unmarshal([]byte(v.String()), &val) ; err!=nil {
func (self *MemoryGenerator) GenerateJsonArray(v *mem.VirtualMemoryStat, cpuNumber string) []string {
timestamp := NowAsUnixMilli()
arr := []string{}
val := make(map[string]interface{})
if err := json.Unmarshal([]byte(v.String()), &val); err != nil {
panic(err)
}
for s,vl := range val{
f ,_ := getFloat(vl)
arr = append(arr, self.GenerateJsonByVal(timestamp,s,f,cpuNumber))
}
for s, vl := range val {
f, _ := getFloat(vl)
arr = append(arr, self.GenerateJsonByVal(timestamp, s, f, cpuNumber))
}
return arr
}


func GetHostname() string {
name, err := os.Hostname()
if err != nil {
panic(err)
} else {
return name }
return name
}
}

var floatType = reflect.TypeOf(float64(0))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package tests
package testing

import (
"fmt"
"github.com/v3io/http_blaster/httpblaster/data_generator"
"testing"
"time"
)

func Test_facker_generator(t *testing.T) {
gen := data_generator.Fake{}
gen.GenerateRandomData()
gen.GenerateRandomData(time.Now())
}

func Test_facker_generator_to_igzemditem(t *testing.T) {
gen := data_generator.Fake{}
gen.GenerateRandomData()
gen.GenerateRandomData(time.Now())
str := gen.ConvertToIgzEmdItemJson()
fmt.Println(str)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package tests
package testing

import (
//"fmt"
"github.com/v3io/http_blaster/httpblaster/data_generator"
//"strings"
"testing"
)

func Test_memeory_generator(t *testing.T) {
gen := data_generator.MemoryGenerator{}
gen.GenerateRandomData("1")
//fmt.Println("["+strings.Join(payloads, ", ")+"]")
}
15 changes: 6 additions & 9 deletions tests/utils_test.go → testing/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package tests
package testing

import (
"github.com/v3io/http_blaster/httpblaster/utils"
"testing"
"time"
)

func Test_utils_print(t *testing.T) {
utils.PrintTime()
}

func Test_utils_generate_year_partitioned_request(t *testing.T) {
str := utils.GeneratePartitionedRequest("year")
str := utils.GeneratePartitionedRequest("year", time.Now())
print(str)
}
func Test_utils_generate_month_partitioned_request(t *testing.T) {
str := utils.GeneratePartitionedRequest("month")
str := utils.GeneratePartitionedRequest("month", time.Now())
print(str)
}
func Test_utils_generate_day_partitioned_request(t *testing.T) {
str := utils.GeneratePartitionedRequest("day")
str := utils.GeneratePartitionedRequest("day", time.Now())
print(str)
}

func Test_utils_generate_hour_partitioned_request(t *testing.T) {
str := utils.GeneratePartitionedRequest("hour")
str := utils.GeneratePartitionedRequest("hour", time.Now())
print(str)
}
61 changes: 0 additions & 61 deletions tests/igz_tsdb_item_test.go

This file was deleted.