github.com/xmidt-org/webpa-common@v1.11.9/service/main_test.go (about)

     1  package service
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"os"
     7  	"sort"
     8  	"strconv"
     9  	"strings"
    10  	"testing"
    11  )
    12  
    13  var (
    14  	vnodeCounts   []int
    15  	addressCounts []int
    16  )
    17  
    18  func TestMain(m *testing.M) {
    19  	var (
    20  		vnodeCountsValue   string
    21  		addressCountsValue string
    22  	)
    23  
    24  	flag.StringVar(&vnodeCountsValue, "vnodeCounts", "100,200,300,400,500", "list of vnode counts to benchmark")
    25  	flag.StringVar(&addressCountsValue, "addressCounts", "1,5,10,50", "list of address counts to benchmark")
    26  	flag.Parse()
    27  
    28  	for _, v := range strings.Split(vnodeCountsValue, ",") {
    29  		i, err := strconv.Atoi(strings.TrimSpace(v))
    30  		if err != nil {
    31  			fmt.Println(err)
    32  			os.Exit(2)
    33  		}
    34  
    35  		vnodeCounts = append(vnodeCounts, i)
    36  	}
    37  
    38  	for _, v := range strings.Split(addressCountsValue, ",") {
    39  		i, err := strconv.Atoi(strings.TrimSpace(v))
    40  		if err != nil {
    41  			fmt.Println(err)
    42  			os.Exit(2)
    43  		}
    44  
    45  		addressCounts = append(addressCounts, i)
    46  	}
    47  
    48  	sort.Ints(vnodeCounts)
    49  	sort.Ints(addressCounts)
    50  	os.Exit(m.Run())
    51  }