2 * Copyright (C) 2015 IBM, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.neutron.e2etest;
11 import java.io.OutputStreamWriter;
13 import java.lang.Thread;
15 import java.net.HttpURLConnection;
18 import org.junit.Assert;
20 public class NeutronLBPoolTests {
23 public NeutronLBPoolTests(String base) {
27 public void pool_collection_get_test() {
28 String url = base + "/lbaas/pools";
29 ITNeutronE2E.test_fetch(url, "LB Pool Collection GET failed");
32 //TODO handle SB check
33 public String singleton_lb_pool_create_test() {
34 String url = base + "/lbaas/pools";
35 String content = "{ \"pool\": { " +
36 "\"admin_state_up\": true, " +
37 "\"description\": \"simple pool\", " +
38 "\"healthmonitor_id\": null, " +
39 "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\", " +
40 "\"lb_algorithm\": \"ROUND_ROBIN\", " +
41 "\"listeners\": [ { " +
42 "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" } ], " +
44 "\"name\": \"pool1\", " +
45 "\"protocol\": \"HTTP\", " +
46 "\"session_persistence\": { " +
47 "\"cookie_name\": \"my_cookie\", " +
48 "\"type\": \"APP_COOKIE\" }, " +
49 "\"tenant_id\": \"b7c1a69e88bf4b21a8148f787aef2081\" } }";
50 ITNeutronE2E.test_create(url, content, "Singleton LB Pool Post Failed NB");
54 public void singleton_lb_pool_get_with_one_query_item_test(String createJsonString) {
55 String url = base + "/lbaas/pools";
56 ITNeutronE2E.test_fetch_with_one_query_item(url, createJsonString, "pools");
59 public void pool_update_test() {
60 String url = base + "/lbaas/pools/12ff63af-4127-4074-a251-bcb2ecc53ebe";
61 String content = " { \"pool\": { \"admin_state_up\": false," +
62 "\"description\": \"pool two\"," +
63 "\"healthmonitor_id\": null," +
64 "\"id\": \"12ff63af-4127-4074-a251-bcb2ecc53ebe\"," +
65 "\"lb_algorithm\": \"LEAST_CONNECTIONS\"," +
66 "\"listeners\": [ {" +
67 "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\" } ]," +
69 "\"name\": \"pool2\"," +
70 "\"protocol\": \"HTTP\"," +
71 "\"session_persistence\": { \"cookie_name\": null," +
72 "\"type\": \"HTTP_COOKIE\" }," +
73 "\"tenant_id\": \"1a3e005cf9ce40308c900bcb08e5320c\" } }";
74 ITNeutronE2E.test_modify(url, content,"LB Pool Put Failed");
77 public void pool_element_get_test() {
78 String url = base + "/lbaas/pools/12ff63af-4127-4074-a251-bcb2ecc53ebe";
79 ITNeutronE2E.test_fetch(url, true ,"LB Pool Element Get Failed");
82 public void pool_element_get_with_query_test() {
83 String url = base + "/lbaas/pools/12ff63af-4127-4074-a251-bcb2ecc53ebe" +
84 "?fields=id&fields=tenant_id&fields=name&fields=description" +
85 "&fields=lb_algorithm&fields=protocol&fields=healthmonitor_id" +
86 "&fields=members&fields=admin_state_up&fields=limit&fields=marker" +
87 "&fields=page_reverse";
88 ITNeutronE2E.test_fetch(url, true ,"LB Pool Element Get With Query Failed");
91 public void pool_element_negative_get_test() {
92 String url = base + "/lbaas/pools/12ff63af-4127-4074-a251-bcb2ecc53ebe";
93 ITNeutronE2E.test_fetch(url, false ,"LB Pool Element Negative Get Failed");
96 public void pool_delete_test() {
97 String url = base + "/lbaas/pools/12ff63af-4127-4074-a251-bcb2ecc53ebe";
98 ITNeutronE2E.test_delete(url, "LB Pool Element Delete Failed");
101 public static void runTests(String base) {
102 NeutronLBPoolTests pool_tester = new NeutronLBPoolTests(base);
103 String createJsonString = pool_tester.singleton_lb_pool_create_test();
104 pool_tester.singleton_lb_pool_get_with_one_query_item_test(createJsonString);
105 pool_tester.pool_update_test();
106 pool_tester.pool_element_get_test();
107 pool_tester.pool_element_get_with_query_test();
108 pool_tester.pool_collection_get_test();
109 pool_tester.pool_delete_test();
110 pool_tester.pool_element_negative_get_test();
111 // needed for pool member testing
112 pool_tester.singleton_lb_pool_create_test();