Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cobra.Command{ Use: "test", Short: "Creates and submits test jobs to the server", Run: func(cmd *cobra.Command, args []string) { log := viper.Get("logger").(zerolog.Logger) if len(args) == 0 { log.Panic().Err(fmt.Errorf("missing arg: endpoint needed")).Int("args", len(args)).Msg("Endpoint needed") return } log.Info(). Int("num", viper.GetInt("number")). Int("req", viper.GetInt("req")). Int("rate", viper.GetInt("rate")). Int("con", viper.GetInt("concurrency")). Int("dur", viper.GetInt("duration")). Str("host", viper.GetString("host")). Str("endpoint", args[0]). Msg("test settings") for i := 0; i < viper.GetInt("number"); i++ { uuid, _ := uuid.NewRandom() b, err := json.Marshal(proto.Job{ ID: uuid.String(), URL: args[0], Req: viper.GetInt("req"), Concurrency: viper.GetInt("concurrency"), Duration: viper.GetInt("duration"), Rate: viper.GetInt("rate"), }) if err != nil { log.Error().Err(err).Str("id", uuid.String()).Msg("error making json payload") return } buf := bytes.NewBuffer(b) resp, err := http.Post(viper.GetString("host"), "application/json", buf) if err != nil { log.Error().Err(err).Str("id", uuid.String()).Msg("error making POST") } log.Info(). Str("status", resp.Status). Int("num", viper.GetInt("number")). Int("req", viper.GetInt("req")). Int("rate", viper.GetInt("rate")). Int("con", viper.GetInt("concurrency")). Int("dur", viper.GetInt("duration")). Str("host", viper.GetString("host")). Str("endpoint", args[0]). Msg("sending job via POST") } log.Info().Msg("complete") }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.