Skip to content

Commit

Permalink
change 9 add SKIP env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ShammiL committed Aug 15, 2024
1 parent 3dd37c1 commit 1ac34ff
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 132 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/all-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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<String, String> 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);
}

}
}

0 comments on commit 1ac34ff

Please sign in to comment.