func validateConcurrency()

in client/concurrency.go [37:110]


func validateConcurrency(url string, functionType string) error {
	log.Printf("%s validation with concurrent requests...", functionType)
	var sendFn func() error
	switch functionType {
	case "http", "typed":
		// Arbitrary JSON payload for compatibility with 'http' and typed JSON tests
		sendFn = func() error {
			_, err := sendHTTP(url, []byte(`{"data": "hello"}`))
			return err
		}
	case "cloudevent":
		// Arbitrary payload that conforms to CloudEvent schema
		sendFn = func() error {
			return send(url, events.CloudEvent, []byte(`{
			"specversion": "1.0",
			"type": "google.firebase.auth.user.v1.created",
			"source": "//firebaseauth.googleapis.com/projects/my-project-id",
			"subject": "users/UUpby3s4spZre6kHsgVSPetzQ8l2",
			"id": "aaaaaa-1111-bbbb-2222-cccccccccccc",
			"time": "2020-09-29T11:32:00.123Z",
			"datacontenttype": "application/json",
			"data": {
			  "email": "test@nowhere.com",
			  "metadata": {
				"createTime": "2020-05-26T10:42:27Z",
				"lastSignInTime": "2020-10-24T11:00:00Z"
			  },
			  "providerData": [
				{
				  "email": "test@nowhere.com",
				  "providerId": "password",
				  "uid": "test@nowhere.com"
				}
			  ],
			  "uid": "UUpby3s4spZre6kHsgVSPetzQ8l2"
			}
		  }`))
		}
	case "legacyevent":
		// Arbitrary payload that conforms to Background event schema
		sendFn = func() error {
			return send(url, events.LegacyEvent, []byte(`{
			"data": {
			  "email": "test@nowhere.com",
			  "metadata": {
				"createdAt": "2020-05-26T10:42:27Z",
				"lastSignedInAt": "2020-10-24T11:00:00Z"
			  },
			  "providerData": [
				{
				  "email": "test@nowhere.com",
				  "providerId": "password",
				  "uid": "test@nowhere.com"
				}
			  ],
			  "uid": "UUpby3s4spZre6kHsgVSPetzQ8l2"
			},
			"eventId": "aaaaaa-1111-bbbb-2222-cccccccccccc",
			"eventType": "providers/firebase.auth/eventTypes/user.create",
			"notSupported": {
			},
			"resource": "projects/my-project-id",
			"timestamp": "2020-09-29T11:32:00.123Z"
		  }`))
		}
	default:
		return fmt.Errorf("expected type to be one of 'http', 'cloudevent', or 'legacyevent', got %s", functionType)
	}
	if err := sendConcurrentRequests(sendFn); err != nil {
		return err
	}
	log.Printf("Concurrency validation passed!")
	return nil
}