c0ab5c7865e0c5db00077b877da0397092fe6eb1
[aai/test-config.git] / gatling / ONAP single API 2022.scala
1 import io.gatling.core.Predef.{exec, _}
2 import io.gatling.http.Predef._
3 import _root_.io.gatling.core.scenario.Simulation
4 import java.util.UUID
5 import scala.concurrent.duration._
6
7 import scala.util.Random
8
9 class ONAP_2204_SingleAPI extends Simulation {
10
11   val httpHeaders = Map(
12     "Accept" -> """application/json""",
13     "Content-Type"-> """application/json""",
14     "X-FromAppId"-> """ONAP-fromappId""",
15     "X-TransactionId"-> """ONAP-transId""",
16     "Connection"-> """Keep-Alive"""
17   )
18
19   def idGenerator() = "random-" + UUID.randomUUID().toString;
20   val feeder = Iterator.continually(Map("randVal" -> (Random.alphanumeric.take(20).mkString)))
21
22   val tenantFeeder = csv("./src/test/gatling/bodies/onaptenants.csv").random
23   val LogLinkFeeder = csv("./src/test/gatling/bodies/onaploglinks.csv").random
24   val PServerFeeder = csv("./src/test/gatling/bodies/onappservers.csv").random
25   val serviceInstanceFeeder = csv("./src/test/gatling/bodies/onapserviceinstance.csv").random
26   val genericvnfFeeder = csv("./src/test/gatling/bodies/onapvnfs.csv").random
27   val CloudRegionFeeder = csv("./src/test/gatling/bodies/onapcloudregions.csv").random
28   val ComplexFeeder = csv("./src/test/gatling/bodies/onapcomplexes.csv").random
29   val customerFeeder = csv("./src/test/gatling/bodies/onapcustomers.csv").random
30   val vfmoduleFeeder = csv("./src/test/gatling/bodies/onapvf-modules.csv").random
31   val pnfFeeder = csv("./src/test/gatling/bodies/onappnfs.csv").random
32
33
34
35
36
37   val host   = System.getProperty("TARGET_HOST", "Enter Host with Port");
38
39   val httpBuilder = http.baseURL(host);
40
41   def SingleAPITest(env: String) = scenario("Run each API single-user " + env)
42
43   /***
44     *
45     * @param env
46     * @PUT tenant
47     */
48 .repeat(3){
49        exec(session => {
50         session.set("stenant", idGenerator())
51       })
52       .exec(
53         http("PutTenant " + env)
54         .put("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner4/onap-CRId4/tenants/tenant/${stenant}")
55         .body(ElFileBody("newtenant_valid.json"))
56         .headers(httpHeaders)
57         .check(
58           status.find.in(201)
59         )
60       )
61       .pause(1,1)
62       .exec(
63         http("GetTenant " + env)
64         .get("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner4/onap-CRId4/tenants/tenant/${stenant}")
65         .headers(httpHeaders)
66         .check(
67           status.find.in(200)
68         )
69         .check(jsonPath("$.resource-version").saveAs("resourcever"))
70       )
71       .exec(
72         http("DeleteTenant " + env)
73         .delete("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner4/onap-CRId4/tenants/tenant/${stenant}?resource-version=${resourcever}")
74         .headers(httpHeaders)
75         .check(status.find.in(204))
76       )
77
78    }
79
80    /***
81     *
82     * @param env
83     * @patch tenant
84     */
85 .repeat(3){
86  // Get the resource version before doing the PATCH
87       feed(tenantFeeder)
88       .exec(
89         http("GetTenant " + env)
90         .get("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenant-patch")
91         .headers(httpHeaders)
92         .check(
93           status.find.in(200)
94         )
95         .check(
96           jsonPath("$.resource-version").saveAs("rsrcver")
97           )
98       )
99
100       .exec(
101         http("PatchTenant " + env)
102         .patch("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenant-patch?resource-version=${rsrcver}")
103         .headers(httpHeaders)
104         .headers(Map(
105           "Content-Type"-> """application/merge-patch+json"""
106         ))
107         .body(ElFileBody("patch-tenant.json"))
108         .check(
109           status.find.in(200)
110         )
111       )
112       .pause(1,1)
113     }
114
115            /***
116     *
117     * @param env
118     * @get tenant depth=0
119     */
120 .repeat(3){
121      feed(tenantFeeder)
122       .exec(
123         http("GetTenantdepth0 " + env)
124         .get("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner3/onap-CRId3/tenants/tenant/onap-tenantId3?depth=0")
125         .headers(httpHeaders)
126         .check(
127           status.find.in(200)
128         )
129       )
130        .pause(1,1)
131     }
132
133                    /***
134     *
135     * @param env
136     * @get vserver-depth=all
137     */
138    .repeat(3){
139        exec(
140           http("GetVserverdepthall " + env)
141           .get("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner2/onap-CRId2/tenants/tenant/onap-tenantId2/vservers/vserver/onap-vserverId2?depth=all")
142           .headers(httpHeaders)
143           .check(
144             status.find.in(200)
145           )
146         )
147        .pause(1,1)
148     }
149
150                            /***
151     *
152     * @param env
153     * @get vserver
154     */
155    .repeat(3){
156          exec(
157           http("GetVserver " + env)
158           .get("/aai/v23/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner2/onap-CRId2/tenants/tenant/onap-tenantId2/vservers/vserver/onap-vserverId2")
159           .headers(httpHeaders)
160           .check(
161             status.find.in(200)
162           )
163         )
164        .pause(1,1)
165     }
166
167                                    /***
168     *
169     * @param env
170     * @get gen-vnf
171     */
172    .repeat(3){
173         feed(genericvnfFeeder)
174         .exec(
175           http("GetVnf " + env)
176           .get("/aai/v23/network/generic-vnfs/generic-vnf/${vnf-id}")
177           .headers(httpHeaders)
178           .check(
179             status.find.in(200)
180           )
181         )
182        .pause(1,1)
183     }
184
185                                            /***
186     *
187     * @param env
188     * @get gen-vnf depth=1
189     */
190    .repeat(3){
191         feed(genericvnfFeeder)
192         .exec(
193           http("GetVnfdepth1 " + env)
194           .get("/aai/v23/network/generic-vnfs/generic-vnf/${vnf-id}?depth=1")
195           .headers(httpHeaders)
196           .check(
197             status.find.in(200)
198           )
199         )
200        .pause(1,1)
201     }
202
203                                                    /***
204     *
205     * @param env
206     * @get vf-module depth=1
207     */
208    .repeat(3){
209         feed(vfmoduleFeeder)
210         .exec(
211           http("GetVfmoduledepthl " + env)
212           .get("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/onap-vnfmoduleId?depth=1")
213           .headers(httpHeaders)
214           .check(
215             status.find.in(200)
216           )
217         )
218        .pause(1,1)
219     }
220
221                                                            /***
222     *
223     * @param env
224     * @put vf-module
225     */
226    .repeat(3){
227         feed(genericvnfFeeder)
228       exec(session => {
229         session.set("svfmodule", idGenerator())
230       })
231       .exec(
232         http("PutVfmodule " + env)
233         .put("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/${svfmodule}")
234         .body(ElFileBody("newvf-module_valid.json"))
235         .headers(httpHeaders)
236         .check(
237           status.find.in(201)
238         )
239       )
240       .pause(1,1)
241       .exec(
242         http("GetVfmodule " + env)
243         .get("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/${svfmodule}")
244         .headers(httpHeaders)
245         .check(
246           status.find.in(200)
247         )
248         .check(jsonPath("$.resource-version").saveAs("resourcever"))
249       )
250 .pause(1,1)
251       .exec(
252         http("DeleteVfmodule " + env)
253         .delete("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/${svfmodule}?resource-version=${resourcever}")
254         .headers(httpHeaders)
255         .check(status.find.in(204))
256       )
257 .pause(1,1)
258
259     }
260
261                                                                    /***
262     *
263     * @param env
264     * @patch/post vf-module
265     */
266    .repeat(3){
267  // Get the resource version before doing the PATCH
268       feed(vfmoduleFeeder)
269       .exec(
270         http("GetVfmodule " + env)
271         .get("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/onap-vnfmoduleId")
272         .headers(httpHeaders)
273         .check(
274           status.find.in(200)
275         )
276         .check(
277           jsonPath("$.resource-version").saveAs("rsrcver")
278           )
279       )
280
281       .exec(
282         http("PatchVfmodule " + env)
283         .patch("/aai/v23/network/generic-vnfs/generic-vnf/onap-genericvnfId/vf-modules/vf-module/onap-vnfmoduleId?resource-version=${rsrcver}")
284         .headers(httpHeaders)
285         .headers(Map(
286           "Content-Type"-> """application/merge-patch+json"""
287         ))
288         .body(ElFileBody("patch-vf-module.json"))
289         .check(
290           status.find.in(200)
291         )
292       )
293
294     }
295
296    /***
297     *
298     * @param env
299     * @get recents api vlan
300     */
301    .repeat(3){
302           exec(
303           http("GetRecentsAPI Vlan " + env)
304           .get("/aai/recents/v23/vlan?hours=192")
305           .headers(httpHeaders)
306           .check(
307             status.find.in(200)
308           )
309         )
310        .pause(1,1)
311     }
312
313         /***
314     *
315     * @param env
316     * @get recents api l-interface
317     */
318    .repeat(3){
319           exec(
320           http("GetRecentsAPI l-interface " + env)
321           .get("/aai/recents/v23/l-interface?hours=192")
322           .headers(httpHeaders)
323           .check(
324             status.find.in(200)
325           )
326         )
327        .pause(1,1)
328     }
329
330     /***
331     *
332     * @param env
333     * @get recents api vserver
334     */
335    .repeat(3){
336           exec(
337           http("GetRecentsAPI vserver " + env)
338           .get("/aai/recents/v23/vserver?hours=192")
339           .headers(httpHeaders)
340           .check(
341             status.find.in(200)
342           )
343         )
344        .pause(1,1)
345     }
346
347             /***
348     *
349     * @param env
350     * @get all CRs1
351     */
352    .repeat(3){
353           exec(
354           http("GetallCR onap-CRId " + env)
355           .get("/aai/v23/cloud-infrastructure/cloud-regions/?cloud-region-id=onap-CRId")
356           .headers(httpHeaders)
357           .check(
358             status.find.in(200)
359           )
360         )
361        .pause(1,1)
362     }
363
364                     /***
365     *
366     * @param env
367     * @get all CRs2
368     */
369    .repeat(3){
370           exec(
371           http("GetallCR onap-CRId " + env)
372           .get("/aai/v23/cloud-infrastructure/cloud-regions/?cloud-region-id=onap-CRId")
373           .headers(httpHeaders)
374           .check(
375             status.find.in(200)
376           )
377         )
378        .pause(1,1)
379     }
380
381                             /***
382     *
383     * @param env
384     * @get all services
385     */
386    .repeat(3){
387           exec(
388           http("GetallServices " + env)
389           .get("/aai/v23/service-design-and-creation/services")
390           .headers(httpHeaders)
391           .check(
392             status.find.in(200)
393           )
394         )
395        .pause(1,1)
396     }
397
398                                     /***
399     *
400     * @param env
401     * @get all CRs
402     */
403    .repeat(3){
404           exec(
405           http("GetallCRs " + env)
406           .get("/aai/v23/cloud-infrastructure/cloud-regions/?cloud-region-id=onap-CRId")
407           .headers(httpHeaders)
408           .check(
409             status.find.in(200)
410           )
411         )
412        .pause(1,1)
413     }
414
415                                             /***
416     *
417     * @param env
418     * @get nodes-query
419     */
420    .repeat(3){
421           exec(
422           http("Getnodes-query VNF " + env)
423           .get("/aai/v23/search/nodes-query?search-node-type=generic-vnf&filter=vnf-name:EQUALS:onap-genericvnfname")
424           .headers(httpHeaders)
425           .check(
426             status.find.in(200)
427           )
428         )
429        .pause(1,1)
430     }
431
432                                                     /***
433     *
434     * @param env
435     * @PUT singletx1
436     */
437     .feed(tenantFeeder)
438         .repeat(3){
439       exec(session => {
440         session.set("sPServer", idGenerator())
441       })
442       .exec(session => {
443         session.set("sVServer", idGenerator())
444       })
445       .exec(
446         http("BulkSingleTx1 " + env)
447         .post("/aai/v22/bulk/single-transaction")
448         .body(ElFileBody("onapbulk-single-tx_putPServerVServer.json"))
449         .headers(httpHeaders)
450         .check(
451           status.find.in(201)
452         )
453       )
454         .pause(2,33)
455         .exec(
456           http("GetVserver " + env)
457           .get("/aai/v22/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenantId1/vservers/vserver/${sVServer}?depth=0&nodes-only=true")
458           .headers(httpHeaders)
459           .check(
460             status.find.in(200)
461           )
462           .check(jsonPath("$.resource-version").saveAs("rsrcver"))
463         )
464         .exec(
465          http("DeleteVserver " + env)
466           .delete("/aai/v22/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenantId1/vservers/vserver/${sVServer}?resource-version=${rsrcver}")
467           .headers(httpHeaders)
468
469           .check(status.find.in(204))
470         )
471         .exec(
472           http("GetPserver " + env)
473           .get("/aai/v22/cloud-infrastructure/pservers/pserver/${sPServer}?depth=0&nodes-only=true")
474           .headers(httpHeaders)
475           .check(
476             status.find.in(200)
477           )
478           .check(jsonPath("$.resource-version").saveAs("rsrcver"))
479         )
480         .exec(
481          http("DeletePserver " + env)
482           .delete("/aai/v22/cloud-infrastructure/pservers/pserver/${sPServer}?resource-version=${rsrcver}")
483           .headers(httpHeaders)
484           .check(status.find.in(204))
485         )
486        .pause(1,1)
487     }
488
489
490                                                             /***
491     *
492     * @param env
493     * @PUT bulksingletx2
494     */
495    .repeat(3){
496      exec(session => {
497         session.set("CR1", idGenerator())
498       })
499       .exec(session => {
500         session.set("AZ1", idGenerator())
501       })
502                 .exec(session => {
503         session.set("flavor1", idGenerator())
504       })
505                 .exec(session => {
506         session.set("image1", idGenerator())
507       })
508                 .exec(session => {
509         session.set("complex1", idGenerator())
510       })
511                 .exec(session => {
512         session.set("pserver1", idGenerator())
513       })
514                 .exec(session => {
515         session.set("pserver2", idGenerator())
516       })
517                 .exec(session => {
518         session.set("pserver3", idGenerator())
519       })
520       .exec(
521         http("BulkSingleTx2 " + env)
522         .post("/aai/v21/bulk/single-transaction")
523         .body(ElFileBody("onap-patch-bulk-single-tx.json"))
524         .headers(httpHeaders)
525         .check(
526           status.find.in(201)
527         )
528       )
529        .pause(1,1)
530     }
531
532                                                                     /***
533     *
534     * @param env
535     * @PUT bulksingletx3
536     */
537     .feed(tenantFeeder)
538         .repeat(3){
539       exec(session => {
540         session.set("sPServer", idGenerator())
541       })
542       .exec(session => {
543         session.set("sVServer", idGenerator())
544       })
545       .exec(
546         http("BulkSingleTx3 " + env)
547         .post("/aai/v22/bulk/single-transaction")
548         .body(ElFileBody("onapbulk-single-tx_putPServerVServer.json"))
549         .headers(httpHeaders)
550         .check(
551           status.find.in(201)
552         )
553       )
554         .pause(2,5)
555         .exec(
556           http("GetVserver " + env)
557           .get("/aai/v22/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenantId1/vservers/vserver/${sVServer}?depth=0&nodes-only=true")
558           .headers(httpHeaders)
559           .check(
560             status.find.in(200)
561           )
562           .check(jsonPath("$.resource-version").saveAs("rsrcver"))
563         )
564         .exec(
565          http("DeleteVserver " + env)
566           .delete("/aai/v22/cloud-infrastructure/cloud-regions/cloud-region/onap-CROwner/onap-CRId/tenants/tenant/onap-tenantId1/vservers/vserver/${sVServer}?resource-version=${rsrcver}")
567           .headers(httpHeaders)
568
569           .check(status.find.in(204))
570         )
571         .exec(
572           http("GetPserver " + env)
573           .get("/aai/v22/cloud-infrastructure/pservers/pserver/${sPServer}?depth=0&nodes-only=true")
574           .headers(httpHeaders)
575           .check(
576             status.find.in(200)
577           )
578           .check(jsonPath("$.resource-version").saveAs("rsrcver"))
579         )
580         .exec(
581          http("DeletePserver " + env)
582           .delete("/aai/v22/cloud-infrastructure/pservers/pserver/${sPServer}?resource-version=${rsrcver}")
583           .headers(httpHeaders)
584           .check(status.find.in(204))
585         )
586        .pause(1,1)
587     }
588
589         /***
590     *
591     * @param env
592     * @CQ pserverzdeviceresurldepth1
593     */
594    .repeat(3){
595        exec(
596           http("CQ pserverzdeviceresurldepth1 " + env)
597           .put("/aai/v22/query?format=resource_and_url&depth=1")
598           .headers(httpHeaders)
599           .body(ElFileBody("onap-CQ-pserver-zdevice.json"))
600           .check(
601             status.find.in(200)
602           )
603         )
604        .pause(1,1)
605     }
606
607         /***
608     *
609     * @param env
610     * @CQ pserverzdeviceres
611     */
612    .repeat(3){
613         exec(
614           http("CQ pserverzdeviceres " + env)
615           .put("/aai/v22/query?format=resource")
616           .headers(httpHeaders)
617           .body(ElFileBody("onap-CQ-pserver-zdevice.json"))
618           .check(
619             status.find.in(200)
620           )
621         )
622        .pause(1,1)
623     }
624
625                 /***
626     *
627     * @param env
628     * @CQ vlanrangefromVlantag
629     */
630    .repeat(3){
631        exec(
632           http("CQ vlanrangefromVlantag " + env)
633           .put("/aai/v22/query?format=resource")
634           .headers(httpHeaders)
635           .body(ElFileBody("onap-CQ-vlanrange-fromVlantag.json"))
636           .check(
637             status.find.in(200)
638           )
639         )
640        .pause(1,1)
641     }
642
643                         /***
644     *
645     * @param env
646     * @CQ pserverzdeviceres
647     */
648    .repeat(3){
649      exec(
650           http("CQ getClfiRoadmTailSummary " + env)
651           .put("/aai/v22/query?format=simple&nodesOnly=true")
652           .headers(httpHeaders)
653           .body(ElFileBody("onap-CQ-getClfiRoadmTailSummary.json"))
654           .check(
655             status.find.in(200)
656           )
657         )
658        .pause(1,1)
659     }
660
661                                 /***
662     *
663     * @param env
664     * @DSL Query1
665     */
666    .repeat(3){
667       exec(
668         http("DSL Query1 PUT")
669         .put("/aai/v21/dsl?format=resource")
670         .headers(httpHeaders)
671         .body(ElFileBody("onap-DSL1.json"))
672         .check(
673           status.find.in(200)
674         )
675       )
676        .pause(1,1)
677     }
678
679                                         /***
680     *
681     * @param env
682     * @DSL Query2
683     */
684    .repeat(3){
685         exec(
686         http("DSL Query2 PUT")
687         .put("/aai/v21/dsl?format=resource")
688         .headers(httpHeaders)
689         .body(ElFileBody("onap-DSL2.json"))
690         .check(
691           status.find.in(200)
692         )
693       )
694        .pause(1,1)
695     }
696
697                                                 /***
698     *
699     * @param env
700     * @DSL Query3
701     */
702    .repeat(3){
703        exec(
704         http("DSL Query3 PUT")
705         .put("/aai/v21/dsl?format=resource")
706         .headers(httpHeaders)
707         .body(ElFileBody("onap-DSL3.json"))
708         .check(
709           status.find.in(200)
710         )
711       )
712        .pause(1,1)
713     }
714
715                                                 /***
716     *
717     * @param env
718     * @DSL Query4
719     */
720    .repeat(3){
721        exec(
722         http("DSL Query4 PUT")
723         .put("/aai/v21/dsl?format=resource")
724         .headers(httpHeaders)
725         .body(ElFileBody("onap-DSL4.json"))
726         .check(
727           status.find.in(200)
728         )
729       )
730        .pause(1,1)
731     }
732
733                                                         /***
734     *
735     * @param env
736     * @2min timeout
737     */
738   .repeat(3){
739           exec(
740           http("GetallCust " + env)
741           .get("/aai/v23/business/customers")
742           .headers(httpHeaders)
743           .check(
744             status.find.in(200)
745           )
746         )
747        .pause(1,1)
748     }
749
750   setUp(
751       SingleAPITest("ePerf02").inject(atOnceUsers(1)).protocols(http.baseURL("Enter Host with Port"))
752   )
753   .maxDuration(10 minutes)
754 }