From 722e8050e6b41f7813fad7094f5e1f4baf6047b5 Mon Sep 17 00:00:00 2001 From: "Garda, Andreea Dora" Date: Thu, 14 May 2015 17:11:21 +0300 Subject: [PATCH 1/4] add to email new process information --- .../verigreen/collector/common/EmailSender.java | 5 +++-- .../collector/decision/OnFailureHandler.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java b/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java index e148f46..af26577 100644 --- a/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java +++ b/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java @@ -122,8 +122,9 @@ public void notifyCommiter( if(result.equals(VerificationStatus.MERGE_FAILED)) { status.append(String.format("Merge failed between commits: %s and %s",parentCommitId.substring(0, 7),commitId.substring(0, 7))); - } - else + } else if(parentCommitId != null) { + status.append(String.format("New process Id:eg_%s", parentCommitId)); + } else { status.append(String.format("Commit Id:%s", commitId.substring(0, 7))); } diff --git a/verigreen-collector-impl/src/main/java/com/verigreen/collector/decision/OnFailureHandler.java b/verigreen-collector-impl/src/main/java/com/verigreen/collector/decision/OnFailureHandler.java index 4368779..6b4e845 100644 --- a/verigreen-collector-impl/src/main/java/com/verigreen/collector/decision/OnFailureHandler.java +++ b/verigreen-collector-impl/src/main/java/com/verigreen/collector/decision/OnFailureHandler.java @@ -48,7 +48,19 @@ protected void doHandle() { _commitItem.getParent().getBranchDescriptor().getCommitId(), _commitItem.getMergedBranchName() ); - } + } else if(!_commitItem.getChildCommit().isEmpty()){ + CollectorApi.getEmailSender().notifyCommiter( + _commitItem.getBranchDescriptor().getCommitId(), + _commitItem.getStatus(), + _commitItem.getBuildUrl(), + "Verigreen Status - Failure", + EmailSender.getFailedSignature(), + _commitItem.getBranchDescriptor().getCommitter(), + _commitItem.getBranchDescriptor().getProtectedBranch(), + _commitItem.getChildCommit(), + _commitItem.getMergedBranchName() + ); + } else { CollectorApi.getEmailSender().notifyCommiter( _commitItem.getBranchDescriptor().getCommitId(), From 2736ea1776a3073880e0d11e040d26b1d34b3895 Mon Sep 17 00:00:00 2001 From: "Garda, Andreea Dora" Date: Mon, 25 May 2015 11:45:24 +0300 Subject: [PATCH 2/4] replace eg_ with vg_ --- .../main/java/com/verigreen/collector/common/EmailSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java b/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java index af26577..be8d246 100644 --- a/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java +++ b/verigreen-collector-impl/src/main/java/com/verigreen/collector/common/EmailSender.java @@ -123,7 +123,7 @@ public void notifyCommiter( { status.append(String.format("Merge failed between commits: %s and %s",parentCommitId.substring(0, 7),commitId.substring(0, 7))); } else if(parentCommitId != null) { - status.append(String.format("New process Id:eg_%s", parentCommitId)); + status.append(String.format("New process Id:vg_%s", parentCommitId)); } else { status.append(String.format("Commit Id:%s", commitId.substring(0, 7))); From 0a06c2c8ba5dec5bf8ab4ea7bc26808b06f801c6 Mon Sep 17 00:00:00 2001 From: "Garda, Andreea Dora" Date: Wed, 10 Jun 2015 12:59:57 +0300 Subject: [PATCH 3/4] add new test --- .../systemtest/TestCollectorE2EGreenPath.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java b/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java index 7e9633c..edfbe8e 100644 --- a/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java +++ b/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java @@ -1375,4 +1375,95 @@ public void testPermittedUsersChangesInRT() throws IOException, InterruptedExcep Assert.assertTrue(ex instanceof RestClientException); } } + + + @Test + public void test2Users() throws IOException, InterruptedException { + String destinationFolderForNewFile = DEFAULT_COMMIT_FOLDER; + long timeoutForTestInMilis = 2000 * 60 * 3; + String commiterName1 = generateUserName(); + String commiterEmail1 = generateEmailAddress(); + String commiterName2 = generateUserName(); + String commiterEmail2 = generateEmailAddress(); + String newFileName1 = generateFileName(); + String newFileName2 = generateFileName(); + + addNewFile( + destinationFolderForNewFile + "/" + newFileName1, + "This is line number 1 in file1 !!!"); + addNewFile( + destinationFolderForNewFile + "/" + newFileName2, + "This is line number 1 in file2 !!!"); + + String content = getContent("getTriggerFailed"); + setProtectedBranch(_masterBranch); + checkoutExistingBranch(_masterBranch); + String originJobName = getJobName(); + changeConfigFileJobName("NotARealJobName"); + + String commitId = + commitAndPush( + destinationFolderForNewFile, + commiterName1, + commiterEmail1, + content, + true, + _masterBranch); + + String shortCommitId = processCommitId(commitId, commiterName1); + checkSuccessfulyProccesedCommitThatShouldFail( + VerigreenUtils.getVerigreenBranchName(shortCommitId), + _masterBranch, + timeoutForTestInMilis, + commitId, + commiterName1, + commiterEmail1, + content, + VerificationStatus.TRIGGER_FAILED, + true); + + String masterBranchCurrentSHA1 = + ((JGitOperator) _sourceControlOperator).getRef( + getBranchRefsRemotesFullName(_masterBranch)).getObjectId().getName(); + + String content2 = getContent("testCommit"); + checkoutExistingBranch(_masterBranch); + changeConfigFileJobName(originJobName); + + String commitId2 = + commitAndPush( + destinationFolderForNewFile, + commiterName2, + commiterEmail2, + content2, + true, + _masterBranch); + String shortCommitId2 = processCommitId(commitId2, commiterName2); + checkSuccessfulyProccesedCommitThatShouldPass( + VerigreenUtils.getVerigreenBranchName(shortCommitId2), + _masterBranch, + _timeoutForTestInMilis, + commitId2, + commiterName2, + commiterEmail2, + content2, + true); + + checkoutExistingBranch(_masterBranch); + //changeConfigFileJobName(originJobName); + setProtectedBranch(VerigreenUtils.getVerigreenBranchName(processCommitId(commitId, commiterName1))); + ((JGitOperator) _sourceControlOperator).reset(masterBranchCurrentSHA1); + _sourceControlOperator.push(_masterBranch, _masterBranch); + checkSuccessfulyProccesedCommitThatShouldFail( + VerigreenUtils.getVerigreenBranchName(shortCommitId), + _masterBranch, + timeoutForTestInMilis, + commitId, + commiterName1, + commiterEmail1, + content, + VerificationStatus.GIT_FAILURE, + true); + + } } \ No newline at end of file From 6cf75a01a89aed4079a04a30b802b476eb35ec76 Mon Sep 17 00:00:00 2001 From: "Garda, Andreea Dora" Date: Tue, 23 Jun 2015 14:44:26 +0300 Subject: [PATCH 4/4] test changes --- .../systemtest/TestCollectorE2EGreenPath.java | 104 ++++++++---------- 1 file changed, 45 insertions(+), 59 deletions(-) diff --git a/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java b/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java index 39cfd7f..1eccb65 100644 --- a/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java +++ b/verigreen-collector-system-tests/utest/com/verigreen/collector/systemtest/TestCollectorE2EGreenPath.java @@ -1378,92 +1378,78 @@ public void testPermittedUsersChangesInRT() throws IOException, InterruptedExcep @Test - public void test2Users() throws IOException, InterruptedException { + public void testScenario() throws IOException, InterruptedException { String destinationFolderForNewFile = DEFAULT_COMMIT_FOLDER; - long timeoutForTestInMilis = 2000 * 60 * 3; - String commiterName1 = generateUserName(); - String commiterEmail1 = generateEmailAddress(); - String commiterName2 = generateUserName(); - String commiterEmail2 = generateEmailAddress(); - String newFileName1 = generateFileName(); - String newFileName2 = generateFileName(); - addNewFile( - destinationFolderForNewFile + "/" + newFileName1, - "This is line number 1 in file1 !!!"); - addNewFile( - destinationFolderForNewFile + "/" + newFileName2, - "This is line number 1 in file2 !!!"); + String masterBranchCurrentSHA1 = + ((JGitOperator) _sourceControlOperator).getRef( + getBranchRefsRemotesFullName(_masterBranch)).getObjectId().getName(); + + String commiterName = generateUserName(); + String commiterEmail = generateEmailAddress(); + String content = getContent("test"); + String[] branch = generateBranchNames(1); - String content = getContent("getTriggerFailed"); setProtectedBranch(_masterBranch); checkoutExistingBranch(_masterBranch); - String originJobName = getJobName(); - changeConfigFileJobName("NotARealJobName"); - + String commitId = commitAndPush( destinationFolderForNewFile, - commiterName1, - commiterEmail1, + commiterName, + commiterEmail, content, true, _masterBranch); - - String shortCommitId = processCommitId(commitId, commiterName1); - checkSuccessfulyProccesedCommitThatShouldFail( + + String shortCommitId = processCommitId(commitId, commiterName); + checkSuccessfulyProccesedCommitThatShouldPass( VerigreenUtils.getVerigreenBranchName(shortCommitId), _masterBranch, - timeoutForTestInMilis, + _timeoutForTestInMilis, commitId, - commiterName1, - commiterEmail1, + commiterName, + commiterEmail, content, - VerificationStatus.TRIGGER_FAILED, true); - - String masterBranchCurrentSHA1 = - ((JGitOperator) _sourceControlOperator).getRef( - getBranchRefsRemotesFullName(_masterBranch)).getObjectId().getName(); - String content2 = getContent("testCommit"); + ((JGitOperator) _sourceControlOperator).reset(masterBranchCurrentSHA1); + createAndPushBranches(branch); + checkoutExistingBranch(branch[0]); + + commitAndPush( + destinationFolderForNewFile, + commiterName, + commiterEmail, + content, + true, + true, + branch[0]); + checkoutExistingBranch(_masterBranch); - changeConfigFileJobName(originJobName); - - String commitId2 = + _sourceControlOperator.merge(_masterBranch,_masterBranch); + _sourceControlOperator.merge(_masterBranch, branch[0]); + + String commitId3 = commitAndPush( destinationFolderForNewFile, - commiterName2, - commiterEmail2, - content2, + commiterName, + commiterEmail, + content, true, _masterBranch); - String shortCommitId2 = processCommitId(commitId2, commiterName2); - checkSuccessfulyProccesedCommitThatShouldPass( - VerigreenUtils.getVerigreenBranchName(shortCommitId2), - _masterBranch, - _timeoutForTestInMilis, - commitId2, - commiterName2, - commiterEmail2, - content2, - true); + + String shortCommitId3 = processCommitId(commitId3, commiterName); - checkoutExistingBranch(_masterBranch); - //changeConfigFileJobName(originJobName); - setProtectedBranch(VerigreenUtils.getVerigreenBranchName(processCommitId(commitId, commiterName1))); - ((JGitOperator) _sourceControlOperator).reset(masterBranchCurrentSHA1); - _sourceControlOperator.push(_masterBranch, _masterBranch); checkSuccessfulyProccesedCommitThatShouldFail( - VerigreenUtils.getVerigreenBranchName(shortCommitId), + VerigreenUtils.getVerigreenBranchName(shortCommitId3), _masterBranch, - timeoutForTestInMilis, - commitId, - commiterName1, - commiterEmail1, + _timeoutForTestInMilis, + commitId3, + commiterName, + commiterEmail, content, VerificationStatus.GIT_FAILURE, true); - } } \ No newline at end of file