-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDF Login using OTA #197
CDF Login using OTA #197
Conversation
3bcdf98
to
cb3c7e2
Compare
screenshotForAllSteps=false | ||
testAccountName=CloudDataFution Automation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Fution->Fusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why, but it actually shows CloudDataFution Automation
on the UI
src/main/java/io/cdap/e2e/pages/actions/CdfPipelineRunAction.java
Outdated
Show resolved
Hide resolved
import static io.cdap.e2e.utils.ConstantsUtil.CDFPASSWORD; | ||
import static io.cdap.e2e.utils.ConstantsUtil.CDFUSERNAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless there is a specific usecase, we should not go for static imports, it makes the code unreadable.
Please use ConstantsUtil.CDFPASSWORD
and so on wherever required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vipinofficial11 can you address comment so that we can get to a closure sooner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated [36bc9cf]
return By.xpath("//span[contains(text(),'Continue')]"); | ||
} | ||
|
||
public static By locatePluginNameInList(String pluginName, String pluginGroupName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This locator is already present in CdfStudioLocators
, can we reuse it??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Locator present in CdfStudioLocators
has return type as WebElement while this one has a return type of By because the use case for both is a bit different.
-
The
locatePluginNameInList
inCdfStudioLocators
is being used to check if we are able to find a plugin in the plugin list. (Here we are using this withWaitHelper.waitForElementToBeDisplayed
) -
The
locatePluginNameInList
inCdfSingInLocators
is being used in sort of a retry mechanism where we are checking if after clicking on the Continue button we are able to see the studio page or a plugin in the plugin list. (Here we are using this withWaitHelper.waitForElementToBeOptionallyDisplayed
)
The locator surely should be moved to CdfStudioLocators
but I don't see a way of reusing the one whose return type is WebElement.
What do you think, is there any way using which we can reuse the locator and achieve both use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented: #197 (comment)
Boolean.parseBoolean(SeleniumHelper.readParameters(ConstantsUtil.TESTONHDF))) { | ||
do { | ||
PageHelper.refreshCurrentPage(); | ||
SeleniumDriver.getWaitDriver(ConstantsUtil.PAGE_LOAD_TIMEOUT_SECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A page refresh in every 50seconds
might be too frequent, it won't change the pipeline status drastically, I would suggest adding a sleep of atleast 2 mins
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the sleep time to 2mins, re-using PIPELINE_DEPLOY_TIMEOUT_SECONDS
as it's value is 120, but the constant name can create some confusion here.
Should we create a new constant with same value named as PIPELINE_REFRESH_TIMEOUT_SECONDS
here ?
(44be5d5#diff-cfa45894e4592a5d6ed32f485ed2594ae01b9a3b154e60820a599164e0b52e80R136)
Made some changes to this function PTAL
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to combine two operations here, why can't we do something like this?
- Click on
element1
if displayed - Click on
element2
if displayed - Wait until
plugin element
is displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason behind creating clickIfDisplayed
was to implement a retry if the element is not displayed on the first attempt.
The reason to combine 2 operations was related to this retry only, the idea was that if once we clicked on the desired element we will validate if the next expected element (3rd parameter) is displayed if we don't see the next element we try to click on the desired element again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this retry be implemented in future? I don't see it being retried in this PR or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Retry logic is actually implemented in clickIfDisplayed
clickIfDisplayed(locatorToClick, timeOutInSeconds);
// If the next webElement is not displayed we will click on the desired element again.
if (!isElementDisplayed(locatorToWaitFor, timeOutInSeconds)) {
logger.info("Retry : Click on " + locatorToClick);
clickIfDisplayed(locatorToClick);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the retry needed? The click should result in the next element within timeout. If we retry, we might initiate the same operation twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this can result in same operation twice, the main purpose of adding the refresh here was to avoid any flakiness in case of CDF login flow because I observed few failed executions while executing the flow. I am not completely sure why but sometimes the click was getting intercepted. (We were waiting for elementToBeClickable still there were some failed executions due to this)
We can remove this refresh and use a simple click with a timeout, I will just have to make sure that there is no flakiness while using a simple click on Cloud Build.
what do you guys suggest ? (cc : @itsankit-google)
ElementHelper.sendKeys(cdfSignInLocator.cdfPassword, SeleniumHelper.readParameters(ConstantsUtil.CDFPASSWORD)); | ||
ElementHelper.clickOnElement(cdfSignInLocator.nextButton); | ||
|
||
// Adding optional operations here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this comment referring to ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the observations in case of CDF test execution from local we encountered an Allow Button and in case of CDF test execution from Cloud Build we encountered Continue Button so to handle this scenario the button clicks were optional.
That's not the case now I see same Continue button on both executions now, so removed the Allow button click and comment as well.
are using 2 confirmation buttons here. | ||
*/ | ||
|
||
String testAccountName = SeleniumHelper.readParameters("testAccountName"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define constant for "testAccountName"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a constant CDF_TEST_ACCOUNT_NAME
for this.
(44be5d5#diff-d1ebf05f182d1decee9527cecadb7ea940ba7cc8dddc7519c80dd3e4b64db94fR40)
@@ -93,4 +96,9 @@ public class ConstantsUtil { | |||
* PIPELINE_RUN_TIMEOUT_SECONDS: To be used as a timeout for Pipeline Runs | |||
*/ | |||
public static final int PIPELINE_RUN_TIMEOUT_SECONDS = 900; | |||
|
|||
/** | |||
* MEDIUM_TIMEOUT_SECONDS: To be used as a wait for retry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make the comment and name specific.
This is used to wait for elemnt to be displayed right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The small timeout works fine here, so removed this Timeout.
/** | ||
* MEDIUM_TIMEOUT_SECONDS: To be used as a wait for retry | ||
*/ | ||
public static final int MEDIUM_TIMEOUT_SECONDS = 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the usage would not SMALL_TIMEOUT_SECONDS work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works on local execution, used SMALL_TIMEOUT_SECONDS
instead of medium everywhere for now.
Note : There is a possibility that due to some external delay in the Login Flow a small timeout may cause some flakiness.
(44be5d5#diff-653a26322c5148b982b3df96f0640a19488ea600b8501ce2695a5218dda8be2bR45)
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnContinueButton(), ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); | ||
|
||
ElementHelper.clickIfDisplayed(cdfSignInLocator.clickOnAllowButton(), ConstantsUtil.MEDIUM_TIMEOUT_SECONDS, | ||
cdfSignInLocator.locatePluginNameInList(ConstantsUtil.FIRST_PLUGIN_IN_LIST, "Source")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the retry needed? The click should result in the next element within timeout. If we retry, we might initiate the same operation twice.
SeleniumDriver.getWaitDriver(ConstantsUtil.PAGE_LOAD_TIMEOUT_SECONDS); | ||
} while (isStarting() || isRunning() || isProvisioning()); | ||
} | ||
|
||
SeleniumDriver.getWaitDriver(ConstantsUtil.PIPELINE_RUN_TIMEOUT_SECONDS).until(ExpectedConditions.or( | ||
ExpectedConditions.visibilityOf(CdfPipelineRunLocators.succeededStatus), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wait seems unneeded based on the above retry which will only stop when the pipeline is in a terminal state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, The purpose of this wait here was if the pipeline is in Running status for more than 15 minutes
we should mark that pipeline as failed to avoid a very long Build execution time.
Now I realised that after the above refresh logic, the do-while loop keep on refreshing the page until the pipeline is in running state which is a problem what if pipeline takes 50-60 mins.
So added a logic in the do-while to break the loop if the pipeline is in running state for more that 900second or 15 mins
also changed the PIPELINE_RUN_TIMEOUT_SECONDS = 900second
to IMPLICIT_TIMEOUT_SECONDS = 30second
to check if Failed || Success || Stop
status is seen.
cc: @itsankit-google
(44be5d5#diff-cfa45894e4592a5d6ed32f485ed2594ae01b9a3b154e60820a599164e0b52e80R122)
// Adding pipelineExecutionTimeFlag to break the loop if pipeline status is Running state for more than | ||
// 900 seconds. | ||
do { | ||
pipelineExecutionTimeFlag += 120; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please define a retry function which takes a retry delay, max retry delay and max retrycount. This can be used both here and in clickIfDisplayed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please make the retry delays as constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the retry function and re-used it for both pipeline refresh and button click. (5c54894)
0c38fc6
to
37bbeee
Compare
37bbeee
to
5c54894
Compare
} | ||
); | ||
|
||
SeleniumDriver.getWaitDriver(ConstantsUtil.IMPLICIT_TIMEOUT_SECONDS).until(ExpectedConditions.or( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks similar to waitTillPipelineRunCompletes
. Please reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-used (66e7a80)
498f799
to
8861cb5
Compare
Merging the PR as it is approved by 2 reviewers (Tested these changes on CDAP as well as on CDF setup) |
Changes for CDF login flow using OTA credentials.