From 1ac34ff51c2fd7ce000feea374aa150ed7b4a916 Mon Sep 17 00:00:00 2001 From: ShammiL Date: Thu, 15 Aug 2024 11:54:28 +0530 Subject: [PATCH] change 9 add SKIP env variable --- .github/workflows/all-tests.yml | 3 +- .../test/odata/ODataETagTestCase.java | 269 +++++++++--------- 2 files changed, 140 insertions(+), 132 deletions(-) diff --git a/.github/workflows/all-tests.yml b/.github/workflows/all-tests.yml index 2331720435..ba7c424b8e 100644 --- a/.github/workflows/all-tests.yml +++ b/.github/workflows/all-tests.yml @@ -20,9 +20,10 @@ jobs: echo "JAVA_TOOL_OPTIONS=$NEW_JAVA_TOOL_OPTIONS" >> $GITHUB_ENV - name: Build with Maven run: | - mvn -B clean install --file pom.xml -fae '-Dtest=!ODataETagTestCase#validateETagConcurrentHandlingTestCaseForDeleteMethod+validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod+validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPatchMethod' + mvn -B clean install --file pom.xml -fae env: JAVA_TOOL_OPTIONS: ${{ env.JAVA_TOOL_OPTIONS }} + SKIP: true # MacOS: # diff --git a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java index 0ae244fce3..6aafce291d 100644 --- a/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java +++ b/integration/dataservice-hosting-tests/tests-integration/tests/src/test/java/org/wso2/ei/dataservice/integration/test/odata/ODataETagTestCase.java @@ -225,151 +225,158 @@ public void validateETagConcurrentHandlingTestCaseForPatchMethod() throws Except @Test(groups = "wso2.dss", description = "etag concurrent handling with delete method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForPatchMethod") public void validateETagConcurrentHandlingTestCaseForDeleteMethod() throws Exception { - String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; - String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; - Map headers = new HashMap<>(); - headers.put("Accept", "application/json"); - Object[] response = sendPOST(endpoint, content, headers); - Assert.assertEquals(response[0], ODataTestUtils.CREATED); - endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; - response = sendGET(endpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String etag = ODataTestUtils.getETag(response[1].toString()); - headers.put("If-None-Match", etag); - int responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - headers.remove("If-None-Match"); - headers.put("If-Match", etag); - responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); - responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND); + System.out.println("SKIP is:" + System.getenv("SKIP").equals("true")); + if (System.getenv("SKIP").equals("true")) { + String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; + String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; + Map headers = new HashMap<>(); + headers.put("Accept", "application/json"); + Object[] response = sendPOST(endpoint, content, headers); + Assert.assertEquals(response[0], ODataTestUtils.CREATED); + endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; + response = sendGET(endpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String etag = ODataTestUtils.getETag(response[1].toString()); + headers.put("If-None-Match", etag); + int responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + headers.remove("If-None-Match"); + headers.put("If-Match", etag); + responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NOT_FOUND); - // To insert values - validateETagRetrievalTestCase(); + // To insert values + validateETagRetrievalTestCase(); - //testing concurrent test with put method - // get the E-Tag - response = sendGET(endpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - etag = getETag(response[1].toString()); - content = "{\"TYPE\" : \"SriLanka\"}"; - headers.remove("If-Match"); - ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); - threadExecutor.run(); - Thread.sleep(1000); - response = sendGET(endpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String tempETag = getETag(response[1].toString()); - Assert.assertNotEquals(etag, tempETag); - headers.put("If-Match", etag); - responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - headers.put("If-Match", tempETag); - responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); - responseCode = sendDELETE(endpoint, headers); - Assert.assertEquals(responseCode, 404); + //testing concurrent test with put method + // get the E-Tag + response = sendGET(endpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + etag = getETag(response[1].toString()); + content = "{\"TYPE\" : \"SriLanka\"}"; + headers.remove("If-Match"); + ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); + threadExecutor.run(); + Thread.sleep(1000); + response = sendGET(endpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String tempETag = getETag(response[1].toString()); + Assert.assertNotEquals(etag, tempETag); + headers.put("If-Match", etag); + responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + headers.put("If-Match", tempETag); + responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + responseCode = sendDELETE(endpoint, headers); + Assert.assertEquals(responseCode, 404); + } } @Test(groups = "wso2.dss", description = "property modification using etag concurrent handling with put method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForDeleteMethod") public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod() throws Exception { // To insert values - String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; - String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; - Map headers = new HashMap<>(); - headers.put("Accept", "application/json"); - Object[] response = sendPOST(endpoint, content, headers); - Assert.assertEquals(response[0], ODataTestUtils.CREATED); - String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String etag = getETag(response[1].toString()); - endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; - content = "{\"value\" : \"Jayasooriya\"}"; - headers.put("If-None-Match", etag); - int responseCode = sendPUT(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - headers.remove("If-None-Match"); - headers.put("If-Match", etag); - responseCode = sendPUT(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + if (System.getenv("SKIP").equals("true")) { + String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES"; + String content = "{\"FILENAME\": \"WSO2PROD\" ,\"TYPE\" : \"dss\"}"; + Map headers = new HashMap<>(); + headers.put("Accept", "application/json"); + Object[] response = sendPOST(endpoint, content, headers); + Assert.assertEquals(response[0], ODataTestUtils.CREATED); + String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String etag = getETag(response[1].toString()); + endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; + content = "{\"value\" : \"Jayasooriya\"}"; + headers.put("If-None-Match", etag); + int responseCode = sendPUT(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + headers.remove("If-None-Match"); + headers.put("If-Match", etag); + responseCode = sendPUT(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); - //testing concurrent test with put method - // get the E-Tag - headers.remove("If-Match"); - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - etag = getETag(response[1].toString()); - content = "{\"value\" : \"SriLanka\"}"; - ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); - threadExecutor.run(); - Thread.sleep(1000); - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String tempETag = getETag(response[1].toString()); - Assert.assertNotEquals(etag, tempETag); - headers.put("If-Match", etag); - content = "{\"value\" : \"DSS Server\"}"; - responseCode = sendPUT(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - // Data validation - headers.remove("If-Match"); - response = sendGET(endpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with put method failed"); - Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with put method failed"); - headers.put("If-Match", tempETag); - responseCode = sendPUT(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + //testing concurrent test with put method + // get the E-Tag + headers.remove("If-Match"); + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + etag = getETag(response[1].toString()); + content = "{\"value\" : \"SriLanka\"}"; + ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); + threadExecutor.run(); + Thread.sleep(1000); + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String tempETag = getETag(response[1].toString()); + Assert.assertNotEquals(etag, tempETag); + headers.put("If-Match", etag); + content = "{\"value\" : \"DSS Server\"}"; + responseCode = sendPUT(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + // Data validation + headers.remove("If-Match"); + response = sendGET(endpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with put method failed"); + Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with put method failed"); + headers.put("If-Match", tempETag); + responseCode = sendPUT(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + } } @Test(groups = "wso2.dss", description = "property modification using etag concurrent handling with patch method test", dependsOnMethods = "validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPutMethod") public void validateETagConcurrentHandlingTestCaseForUpdatePropertyWithPatchMethod() throws Exception { - String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; - String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; - Map headers = new HashMap<>(); - headers.put("Accept", "application/json"); - Object[] response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String etag = getETag(response[1].toString()); - String content = "{\"value\" : \"Jayasooriya\"}"; - headers.put("If-None-Match", etag); - int responseCode = sendPATCH(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - headers.remove("If-None-Match"); - headers.put("If-Match", etag); - responseCode = sendPATCH(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + if (System.getenv("SKIP").equals("true")) { + String entityEndpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')"; + String endpoint = webAppUrl + "/odata/" + serviceName + "/" + configId + "/FILES(\'WSO2PROD\')/TYPE"; + Map headers = new HashMap<>(); + headers.put("Accept", "application/json"); + Object[] response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String etag = getETag(response[1].toString()); + String content = "{\"value\" : \"Jayasooriya\"}"; + headers.put("If-None-Match", etag); + int responseCode = sendPATCH(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + headers.remove("If-None-Match"); + headers.put("If-Match", etag); + responseCode = sendPATCH(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); - //testing concurrent test with put method - // get the E-Tag - headers.remove("If-Match"); - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - etag = getETag(response[1].toString()); - content = "{\"value\" : \"SriLanka\"}"; - ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); - threadExecutor.run(); - Thread.sleep(1000); - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - String tempETag = getETag(response[1].toString()); - Assert.assertNotEquals(etag, tempETag); - headers.put("If-Match", etag); - content = "{\"value\" : \"DSS Server\"}"; - responseCode = sendPATCH(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); - // Data validation - headers.remove("If-Match"); - response = sendGET(entityEndpoint, headers); - Assert.assertEquals(response[0], ODataTestUtils.OK); - Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with patch method failed"); - Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with patch method failed"); - headers.put("If-Match", tempETag); - responseCode = sendPATCH(endpoint, content, headers); - Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + //testing concurrent test with put method + // get the E-Tag + headers.remove("If-Match"); + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + etag = getETag(response[1].toString()); + content = "{\"value\" : \"SriLanka\"}"; + ODataRequestThreadExecutor threadExecutor = new ODataRequestThreadExecutor("PUT", content, headers, endpoint); + threadExecutor.run(); + Thread.sleep(1000); + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + String tempETag = getETag(response[1].toString()); + Assert.assertNotEquals(etag, tempETag); + headers.put("If-Match", etag); + content = "{\"value\" : \"DSS Server\"}"; + responseCode = sendPATCH(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.PRE_CONDITION_FAILED); + // Data validation + headers.remove("If-Match"); + response = sendGET(entityEndpoint, headers); + Assert.assertEquals(response[0], ODataTestUtils.OK); + Assert.assertFalse(response[1].toString().contains("DSS Server"), "E-Tag with patch method failed"); + Assert.assertTrue(response[1].toString().contains("SriLanka"), "E-Tag with patch method failed"); + headers.put("If-Match", tempETag); + responseCode = sendPATCH(endpoint, content, headers); + Assert.assertEquals(responseCode, ODataTestUtils.NO_CONTENT); + } } }