Skip to content

Commit

Permalink
added retry mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkitCLI committed Oct 21, 2024
1 parent a1a4049 commit 7569f33
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ jobs:
- name: Run all e2e tests
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || steps.filter.outputs.e2e-test == 'true'
run: python3 e2e/src/main/scripts/run_e2e_test.py --testRunner **/${{ matrix.tests }}/**/TestRunner.java
# Step to check if there were failures and run retry runner if needed
- name: Check for Failed Tests and Run Retry Runner
if: always() # Always run this step to check for failures
run: if [ -f ./plugin/target/failed_scenarios.txt ]; then
echo "Found failed scenarios. Running retry tests."
python3 e2e/src/main/scripts/run_e2e_test.py --testRunner **/${{ matrix.tests }}/**/RetryTestRunner.java
else
echo "No failed scenarios found."
fi
- name: Upload debug files
uses: actions/upload-artifact@v3
if: always()
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@
<properties>
<testSourceLocation>src/e2e-test/java</testSourceLocation>
<TEST_RUNNER>TestRunner.java</TEST_RUNNER>
<RETRY_RUNNER>RetryTestRunner.java</RETRY_RUNNER>
</properties>
<build>
<testResources>
Expand Down Expand Up @@ -1254,6 +1255,18 @@
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>retry-failed-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>${RETRY_RUNNER}</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/bigquerymultitable-sink",
"json:target/cucumber-reports/cucumber-bigquerymultitable-sink.json",
"junit:target/cucumber-reports/cucumber-bigquerymultitable-sink.xml"}
"junit:target/cucumber-reports/cucumber-bigquerymultitable-sink.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/bigquery-sink",
"json:target/cucumber-reports/cucumber-bigquery-sink.json",
"junit:target/cucumber-reports/cucumber-bigquery-sink.xml"}
"junit:target/cucumber-reports/cucumber-bigquery-sink.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/bigquery-source",
"json:target/cucumber-reports/cucumber-bigquery-source.json",
"junit:target/cucumber-reports/cucumber-bigquery-source.xml"}
"junit:target/cucumber-reports/cucumber-bigquery-source.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/bqExecute",
"json:target/cucumber-reports/cucumber-bqExecute.json",
"junit:target/cucumber-reports/cucumber-bqExecute.xml"}
"junit:target/cucumber-reports/cucumber-bqExecute.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/bigtable",
"json:target/cucumber-reports/cucumber-bigtable.json",
"junit:target/cucumber-reports/cucumber-bigtable.xml"}
"junit:target/cucumber-reports/cucumber-bigtable.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright © 2021 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.cdap.plugin.common.runners.common;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

/**
* Retry Test Runner to execute failed scenarios test cases.
*/
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"@target/failed_scenarios.txt"}, // This reruns only failed scenarios,
glue = {"io.cdap.plugin.gcs.stepsdesign", "io.cdap.plugin.bigquery.stepsdesign", "stepsdesign",
"io.cdap.plugin.common.stepsdesign", "io.cdap.plugin.pubsub.stepsdesign",
"io.cdap.plugin.gcsmove.stepsdesign", "io.cdap.plugin.spanner.stepsdesign",
"io.cdap.plugin.gcsdelete.stepsdesign"},
monochrome = true,
plugin = {"pretty", "json:target/cucumber-reports/failed-scenarios.json"}
)
public class RetryTestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/datastore",
"json:target/cucumber-reports/cucumber-datastore.json",
"junit:target/cucumber-reports/cucumber-datastore.xml"}
"junit:target/cucumber-reports/cucumber-datastore.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcs-sink",
"json:target/cucumber-reports/cucumber-gcs-sink.json",
"junit:target/cucumber-reports/cucumber-gcs-sink.xml"}
"junit:target/cucumber-reports/cucumber-gcs-sink.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcs-source",
"json:target/cucumber-reports/cucumber-gcs-source.json",
"junit:target/cucumber-reports/cucumber-gcs-source.xml"}
"junit:target/cucumber-reports/cucumber-gcs-source.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcscopy-action",
"json:target/cucumber-reports/cucumber-gcscopy-action.json",
"junit:target/cucumber-reports/cucumber-gcscopy-action.xml"}
"junit:target/cucumber-reports/cucumber-gcscopy-action.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcscreate",
"json:target/cucumber-reports/cucumber-gcscreate.json",
"junit:target/cucumber-reports/cucumber-gcscreate.xml"}
"junit:target/cucumber-reports/cucumber-gcscreate.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcsdelete",
"json:target/cucumber-reports/cucumber-gcsdelete.json",
"junit:target/cucumber-reports/cucumber-gcsdelete.xml"}
"junit:target/cucumber-reports/cucumber-gcsdelete.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/gcsmove-action",
"json:target/cucumber-reports/cucumber-gcsmove-action.json",
"junit:target/cucumber-reports/cucumber-gcsmove-action.xml"}
"junit:target/cucumber-reports/cucumber-gcsmove-action.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/pubsub-sink",
"json:target/cucumber-reports/cucumber-pubsub-sink.json",
"junit:target/cucumber-reports/cucumber-pubsub-sink.xml"}
"junit:target/cucumber-reports/cucumber-pubsub-sink.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)

public class TestRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/spanner-sink",
"json:target/cucumber-reports/cucumber-spanner-sink.json",
"junit:target/cucumber-reports/cucumber-spanner-sink.xml"}
"junit:target/cucumber-reports/cucumber-spanner-sink.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
monochrome = true,
plugin = {"pretty", "html:target/cucumber-html-report/spanner-source",
"json:target/cucumber-reports/cucumber-spanner-source.json",
"junit:target/cucumber-reports/cucumber-spanner-source.xml"}
"junit:target/cucumber-reports/cucumber-spanner-source.xml",
"rerun:target/failed_scenarios.txt"} // Store failed scenarios here}}
)
public class TestRunner {
}

0 comments on commit 7569f33

Please sign in to comment.