예제 #1
0
func main() {
	scamp.Initialize("/etc/GTSOA/soa.conf")

	var wg sync.WaitGroup

	for j := 0; j < 1; j++ {
		wg.Add(1)
		go func() {
			client, err := scamp.Dial("0.0.0.0:63531")
			if err != nil {
				scamp.Error.Printf("could not dial service: `%s`", err)
				return
			}

			for i := 0; i < 1; i++ {
				reqId := i + 1
				wg.Add(1)
				go func() {
					msg := scamp.NewRequestMessage()
					msg.SetAction("verify")
					msg.SetRequestId(reqId)
					scamp.Info.Printf("reqId: %d", reqId)

					var req SqrtRequest
					req.Input = rand.NormFloat64()

					expSqrt := math.Sqrt(req.Input)

					var expResp SqrtResponse
					if math.IsNaN(expSqrt) {
						expResp.NaN = true
					} else {
						expResp.Output = expSqrt
					}
					expBytes, err := json.Marshal(expResp)
					if err != nil {
						scamp.Info.Printf("could not marshal exp resp: `%s`", err)
						return
					}

					msg.WriteJson(req)
					respChan, err := client.Send(msg)
					if err != nil {
						scamp.Error.Printf("could not send message: `%s`", err)
					}
					resp := <-respChan
					if !bytes.HasPrefix(resp.Bytes(), expBytes) {
						scamp.Error.Printf("response did not match: got `%s`, expected `%s`", string(resp.Bytes()), string(expBytes))
						os.Exit(1)
					}
					// scamp.Info.Printf("resp: %s", resp.Bytes())
					wg.Done()
				}()
			}
			wg.Done()
		}()
	}

	wg.Wait()
}
예제 #2
0
func (sop *SCAMPOutputPlugin) Init(config interface{}) (err error) {
	scamp.Initialize(scamp.DefaultConfigPath)

	sop.conf = config.(*SCAMPOutputPluginConfig)

	scamp.Info.Printf("Connecting to %s\n", sop.conf.Service)
	sop.client, err = scamp.Dial(sop.conf.Service)
	if err != nil {
		return
	}

	return
}
예제 #3
0
func main() {
	scamp.Initialize()

	var clients []*scamp.Client = make([]*scamp.Client, 10000)

	var wg sync.WaitGroup

	for i := range clients {
		client, err := scamp.Dial("127.0.0.1:30100")
		if err != nil {
			scamp.Error.Fatalf("could not connect! `%s`\n", err)
			return
		}

		clients[i] = client

		wg.Add(1)
		go hitService(client, wg)
	}

	scamp.Info.Printf("waiting for stress to finish")
	wg.Wait()
	scamp.Info.Printf("done with stress")
}