All Downloads are FREE. Search and download functionalities are using the official Maven repository.

activities.documents-api.http-docsapi-crud-basic.yaml Maven / Gradle / Ivy

# nb -v run driver=http yaml=http-docsapi-crud-basic tags=phase:schema stargate_host=my_stargate_host auth_token=$AUTH_TOKEN

description: |
  This workload emulates CRUD operations for the Stargate Documents API.
  It generates a simple JSON document to be used for writes and updates.
  Note that stargate_port should reflect the port where the Docs API is exposed (defaults to 8082).

scenarios:
  default:
    schema:   run driver=http tags==phase:schema threads==1 cycles==UNDEF
    write:    run driver=http tags==phase:main,type:write cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    read:     run driver=http tags==phase:main,type:read cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    update:   run driver=http tags==phase:main,type:update cycles===TEMPLATE(update-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn
    delete:   run driver=http tags==phase:main,type:delete cycles===TEMPLATE(delete-cycles,TEMPLATE(docscount,10000000)) threads=auto errors=timer,warn

bindings:
  # To enable an optional weighted set of hosts in place of a load balancer
  # Examples
  #   single host: stargate_host=host1
  #   multiple hosts: stargate_host=host1,host2,host3
  #   multiple weighted hosts: stargate_host=host1:3,host2:7
  weighted_hosts: WeightedStrings('<>')
  # http request id
  request_id: ToHashedUUID(); ToString();

  seq_key: Mod(<>); ToString() -> String
  random_key: Uniform(0,<>); ToString() -> String

  user_id: ToHashedUUID(); ToString() -> String
  created_on: Uniform(1262304000,1577836800) -> long
  gender: WeightedStrings('M:10;F:10;O:1')
  full_name: FullNames()
  married: ModuloToBoolean()
  city: Cities()
  country_code: CountryCodes()
  lat: Uniform(-180d, 180d)
  lng: Hash() -> long; Uniform(-180d, 180d)
  friend_id: Add(-1); ToHashedUUID(); ToString() -> String

blocks:
  - tags:
      phase: schema
    statements:
      - create-keyspace: POST <>://{weighted_hosts}:<><>/v2/schemas/keyspaces
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
          {
              "name": "<>",
              "replicas": <>
          }
        tags:
          name: create-keyspace

      - delete-docs-collection: DELETE <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        tags:
          name: delete-table
        ok-status: "[2-4][0-9][0-9]"

      - create-docs-collection: POST <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
          {
              "name": "<>"
          }
        tags:
          name: create-table

  - name: main-write
    tags:
      phase: main
      type: write
    statements:
      - write-document: PUT <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key}
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
          {
            "user_id":      "{user_id}",
            "created_on":   {created_on},
            "gender":       "{gender}",
            "full_name":    "{full_name}",
            "married":      {married},
            "address": {
              "primary": {
                  "city":   "{city}",
                  "cc":     "{country_code}"
              },
              "secondary":  {}
            },
            "coordinates": [
                            {lat},
                            {lng}
            ],
            "children":     [],
            "friends": [
                            "{friend_id}"
            ],
            "debt":         null
          }
        tags:
          name: write-document

  - name: main-read
    tags:
      phase: main
      type: read
    statements:
      - read-document: GET <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key}
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        ok-status: "[2-4][0-9][0-9]"
        tags:
          name: read-document

  - name: main-update
    tags:
      phase: main
      type: update
    statements:
      - update-document: PUT <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{random_key}
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        Content-Type: "application/json"
        body: |
          {
            "user_id":      "{user_id}",
            "created_on":   {created_on},
            "gender":       "{gender}",
            "full_name":    "{full_name}",
            "married":      {married},
            "address": {
              "primary": {
                  "city":   "{city}",
                  "cc":     "{country_code}"
              },
              "secondary":  {}
            },
            "coordinates": [
                            {lat},
                            {lng}
            ],
            "children":     [],
            "friends": [
                            "{friend_id}"
            ],
            "debt":         null
          }
        tags:
          name: update-document

  - name: main-delete
    tags:
      phase: main
      type: delete
    statements:
      - delete-document: DELETE <>://{weighted_hosts}:<><>/v2/namespaces/<>/collections/<>/{seq_key}
        Accept: "application/json"
        X-Cassandra-Request-Id: "{request_id}"
        X-Cassandra-Token: "<>"
        ok-status: "[2-4][0-9][0-9]"
        tags:
          name: delete-document




© 2015 - 2025 Weber Informatics LLC | Privacy Policy