Home > Mobile >  Gatling feeder/parameter issue - Exception in thread "main" java.lang.UnsupportedOperation
Gatling feeder/parameter issue - Exception in thread "main" java.lang.UnsupportedOperation

Time:09-08

I just involved the new project for API test for our service by using Gatling. At this point, I want to search query, below is the code:

def chnSendToRender(testData: FeederBuilderBase[String]): ChainBuilder = {

 feed(testData)

  exec(api.AdvanceSearch.searchAsset(s"{\"all\":[{\"all:aggregate:text\":{\"contains\":\"#{edlAssetId}_Rendered\"}}]}", "#{authToken}")
   .check(status.is(200).saveAs("searchStatus"))
   .check(jsonPath("$..asset:id").findAll.optional.saveAs("renderedAssetList"))
    )
      
 .doIf(session => session("searchStatus").as[Int] == 200) {
        exec { session =>
          printConsoleLog("Rendered Asset ID List: "   session("renderedAssetList").as[String], "INFO")
          session
        }
      }
  }

I declared the feeder already in the simulation scala file:

class GVRERenderEditor_new extends Simulation {

private val edlToRender = csv("data/render/edl_asset_ids.csv").queue

private val chnPostRender = components.notifications.notice.JobsPolling_new.chnSendToRender(edlToRender)

private val scnSendEDLForRender = scenario("Search Post Render")
.exitBlockOnFail(exec(preSimAuth))
.exec(chnPostRender)

setUp(
scnSendEDLForRender.inject(atOnceUsers(1)).protocols(httpProtocol)
)
.maxDuration(sessionDuration.seconds)
.assertions(global.successfulRequests.percent.is(100))

}

But Gatling test failed to run, showing this error: Exception in thread "main" java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated

If I hardcode the #{edlAssetId} (put the real edlAssetId in that query), I will get result. I think I passed the parameter wrongly in this case. I've tried to print the output in console log but no luck. What's wrong with this code? I would appreciate your help. Thanks!

CodePudding user response:

 feed(testData)

  exec(api.AdvanceSearch.searchAsset(s"{\"all\":[{\"all:aggregate:text\":{\"contains\":\"#{edlAssetId}_Rendered\"}}]}", "#{authToken}")
   .check(status.is(200).saveAs("searchStatus"))
   .check(jsonPath("$..asset:id").findAll.optional.saveAs("renderedAssetList"))
    )

You're missing a . (dot) before the exec to attach it to the feed.

As a result, your method is returning the last instruction, ie the exec only.

  • Related