From 7c15d9d08c3d1f18e8098b3ccd85e8af1c48d1f2 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 23 Jul 2020 09:05:16 -0700 Subject: [PATCH 01/48] add files to react branch --- .travis.yml | 46 ++++++++++++++++++++++++++++++++++++++++ requirements.txt | 4 ++++ tests/test_slurm.py | 51 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 .travis.yml create mode 100644 requirements.txt create mode 100644 tests/test_slurm.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f46ebb8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,46 @@ + +language: python +dist: bionic +# python: +# - '3.6' +# - '3.7' +# nodejs: +# - 10.0.0 +# os: osx +# command to run tests +cache: pip +env: + global: + - MOZ_HEADLESS=1 +addons: + firefox: "78.0.1" +sudo: required +services: + - xvfb +before_install: + - sudo apt-get install xvfb + - wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz + # - mkdir geckodriver + # - tar -xzf geckodriver-v0.26.0-macos.tar.gz -C geckodriver + # - export PATH=$PATH:$PWD/geckodriver + - sudo tar -xzf geckodriver-v0.26.0-linux64.tar.gz -C /usr/bin + - sudo chmod a+x /usr/bin/geckodriver + # - export DISPLAY=:99.0 + # - sh -e /etc/init.d/xvfb start + # - sleep 5 # give xvfb some time to start +install: + - "pip install -r requirements.txt" + - npm install selenium-webdriver@^3.0.0 + - curl -o- -L https://yarnpkg.com/install.sh | bash + - node --version + - jupyter --version + - jlpm install + - jlpm run build + - jupyter labextension install + + +script: + - jupyter labextension list + - jupyter lab --port=8845 --NotebookApp.token='' & + - pytest + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5040219 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +jupyter +jupyterlab>2.0.0 +selenium +pytest diff --git a/tests/test_slurm.py b/tests/test_slurm.py new file mode 100644 index 0000000..966e60b --- /dev/null +++ b/tests/test_slurm.py @@ -0,0 +1,51 @@ +import pytest +import time +import json +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.support import expected_conditions +from selenium.webdriver.support.wait import WebDriverWait +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + +class TestAddfavs(): + def setup_method(self, method): + self.driver = webdriver.Firefox() + self.vars = {} + + def teardown_method(self, method): + self.driver.quit() + + def test_checktext(self): + self.driver.get("http://localhost:8845/lab") + self.driver.implicitly_wait(10000) + self.driver.maximize_window() + #WebDriverWait(self.driver, 1000) + + #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + #assert card_text.text == "Slurm Queue" + slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + assert slurm_card.text == "Slurm Queue" + #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + self.driver.implicitly_wait(5000) + actions = ActionChains(self.driver) + self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") + actions.click(slurm_card).perform() + self.driver.implicitly_wait(10000) + actions.click(slurm_card).perform() + # WebDriverWait(self.driver, 5000) + self.driver.implicitly_wait(10000) + + slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") + # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") + assert slurm_tab.text == "Slurm Queue Manager" + + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + actions = ActionChains(self.driver) + actions.click(close_tab).perform() + +if __name__ == '__main__': + setup_method() + test_checktext() + teardown_method() \ No newline at end of file From b4b237892e906425361004b794806de8c489df2b Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 23 Jul 2020 09:18:29 -0700 Subject: [PATCH 02/48] add branch travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index f46ebb8..3aa44d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,10 @@ addons: sudo: required services: - xvfb +branches: + only: + - master + - react before_install: - sudo apt-get install xvfb - wget https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz From 40d17d604e05b25feee4afc3c6712f989acca781 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 23 Jul 2020 09:34:39 -0700 Subject: [PATCH 03/48] reduce wait times --- tests/test_slurm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 966e60b..44fc026 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -19,7 +19,7 @@ def teardown_method(self, method): def test_checktext(self): self.driver.get("http://localhost:8845/lab") - self.driver.implicitly_wait(10000) + self.driver.implicitly_wait(30) self.driver.maximize_window() #WebDriverWait(self.driver, 1000) @@ -28,14 +28,14 @@ def test_checktext(self): slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") assert slurm_card.text == "Slurm Queue" #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - self.driver.implicitly_wait(5000) + self.driver.implicitly_wait(30) actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") actions.click(slurm_card).perform() - self.driver.implicitly_wait(10000) + self.driver.implicitly_wait(30) actions.click(slurm_card).perform() # WebDriverWait(self.driver, 5000) - self.driver.implicitly_wait(10000) + self.driver.implicitly_wait(30) slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") From 23cc59ebf83ba2d8fec7dd2207e741ac13f6e91a Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 24 Jul 2020 09:55:33 -0700 Subject: [PATCH 04/48] local test passes --- tests/test_slurm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 44fc026..10bfad6 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -32,12 +32,13 @@ def test_checktext(self): actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") actions.click(slurm_card).perform() - self.driver.implicitly_wait(30) - actions.click(slurm_card).perform() + self.driver.implicitly_wait(10) + #actions.click(slurm_card).perform() # WebDriverWait(self.driver, 5000) self.driver.implicitly_wait(30) - slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") + slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") + #li.p-mod-current:nth-child(2) > div:nth-child(2) # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") assert slurm_tab.text == "Slurm Queue Manager" From 90b6219fc11c7cf3e342b340d702034c0614c4fd Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 24 Jul 2020 10:37:51 -0700 Subject: [PATCH 05/48] add waits --- tests/test_slurm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 10bfad6..a988d89 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -21,11 +21,13 @@ def test_checktext(self): self.driver.get("http://localhost:8845/lab") self.driver.implicitly_wait(30) self.driver.maximize_window() + self.driver.implicitly_wait(30) #WebDriverWait(self.driver, 1000) #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + self.driver.implicitly_wait(30) assert slurm_card.text == "Slurm Queue" #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") self.driver.implicitly_wait(30) From 678bd22987df8765d9114dc51d0ae9b3106b27b6 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 24 Jul 2020 10:45:10 -0700 Subject: [PATCH 06/48] change to css selector --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index a988d89..6ca44ec 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -39,8 +39,8 @@ def test_checktext(self): # WebDriverWait(self.driver, 5000) self.driver.implicitly_wait(30) - slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") - #li.p-mod-current:nth-child(2) > div:nth-child(2) + #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") + slurm_tab = self.driver.find_element_by_css_selector("li.p-mod-current:nth-child(2) > div:nth-child(2)") # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") assert slurm_tab.text == "Slurm Queue Manager" From b048b32fdc4fce912bf3b7ea15446086b10fbbad Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 24 Jul 2020 10:53:24 -0700 Subject: [PATCH 07/48] click on card twice --- tests/test_slurm.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 6ca44ec..62bc040 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -34,9 +34,7 @@ def test_checktext(self): actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") actions.click(slurm_card).perform() - self.driver.implicitly_wait(10) - #actions.click(slurm_card).perform() - # WebDriverWait(self.driver, 5000) + actions.click(slurm_card).perform() self.driver.implicitly_wait(30) #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") From 0894c9f0f2223891d5f886503806559c4fefa872 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Mon, 27 Jul 2020 09:40:59 -0700 Subject: [PATCH 08/48] add jobid partition assert --- tests/test_slurm.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 62bc040..7024d07 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -38,9 +38,16 @@ def test_checktext(self): self.driver.implicitly_wait(30) #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") - slurm_tab = self.driver.find_element_by_css_selector("li.p-mod-current:nth-child(2) > div:nth-child(2)") + # slurm_tab = self.driver.find_element_by_css_selector("li.p-mod-current:nth-child(2) > div:nth-child(2)") # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") - assert slurm_tab.text == "Slurm Queue Manager" + # assert slurm_tab.text == "Slurm Queue Manager" + + # jobid_text = self.driver.find_element(By.XPATH, "//div[contains(text(),'JOBID')]") + jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" + + partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") actions = ActionChains(self.driver) From 58f6b08908a9a432a4e9d30e260dcf9f6c417d89 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Mon, 27 Jul 2020 10:45:40 -0700 Subject: [PATCH 09/48] remove slick card --- tests/test_slurm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 7024d07..67bdb1c 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -27,6 +27,9 @@ def test_checktext(self): #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + #slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + #slurm_card = self.driver.find_elements_by_class_name("jp-LauncherCard") + self.driver.implicitly_wait(30) assert slurm_card.text == "Slurm Queue" #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") @@ -34,7 +37,7 @@ def test_checktext(self): actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") actions.click(slurm_card).perform() - actions.click(slurm_card).perform() + #actions.click(slurm_card).perform() self.driver.implicitly_wait(30) #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") From 341ab39f3248740dc7405303b8bf207d07c539f3 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Mon, 27 Jul 2020 10:57:53 -0700 Subject: [PATCH 10/48] change slrum card to contains --- tests/test_slurm.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 67bdb1c..ed1c272 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -23,11 +23,13 @@ def test_checktext(self): self.driver.maximize_window() self.driver.implicitly_wait(30) #WebDriverWait(self.driver, 1000) +div.jp-Launcher-section:nth-child(5) > div:nth-child(2) > div:nth-child(1) + #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" - slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - #slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + # slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") #slurm_card = self.driver.find_elements_by_class_name("jp-LauncherCard") self.driver.implicitly_wait(30) From 220dffa336db2ec334794d67d0857982676db3cb Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Mon, 27 Jul 2020 11:03:52 -0700 Subject: [PATCH 11/48] comment error --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index ed1c272..8f07343 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -23,7 +23,7 @@ def test_checktext(self): self.driver.maximize_window() self.driver.implicitly_wait(30) #WebDriverWait(self.driver, 1000) -div.jp-Launcher-section:nth-child(5) > div:nth-child(2) > div:nth-child(1) +#div.jp-Launcher-section:nth-child(5) > div:nth-child(2) > div:nth-child(1) #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") From 1f4cedb86785d2008f6fbd1b0d9f78141b280de4 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Mon, 27 Jul 2020 11:48:24 -0700 Subject: [PATCH 12/48] find card by class --- tests/test_slurm.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 8f07343..3e3c402 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -18,6 +18,8 @@ def teardown_method(self, method): self.driver.quit() def test_checktext(self): + #import pdb; pdb.set_trace() + self.driver.get("http://localhost:8845/lab") self.driver.implicitly_wait(30) self.driver.maximize_window() @@ -28,17 +30,17 @@ def test_checktext(self): #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" - # slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #slurm_card = self.driver.find_elements_by_class_name("jp-LauncherCard") + #slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + #slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') - self.driver.implicitly_wait(30) - assert slurm_card.text == "Slurm Queue" + self.driver.implicitly_wait(10) + #assert slurm_card.text == "Slurm Queue" #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - self.driver.implicitly_wait(30) + self.driver.implicitly_wait(10) actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") - actions.click(slurm_card).perform() + actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() self.driver.implicitly_wait(30) From 0203ee55e6bafd49e511947e9763ac14f60db584 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 00:53:58 -0700 Subject: [PATCH 13/48] edit travis sleep --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3aa44d1..036d031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,5 +46,6 @@ install: script: - jupyter labextension list - jupyter lab --port=8845 --NotebookApp.token='' & + - sleep 30 - pytest From ade99fbaad44b0453a7b4bc0d26ebfe63a4b3ab7 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 01:03:26 -0700 Subject: [PATCH 14/48] edit pytest --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 3e3c402..5fe6565 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -34,7 +34,7 @@ def test_checktext(self): #slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') - self.driver.implicitly_wait(10) + # self.driver.implicitly_wait(10) #assert slurm_card.text == "Slurm Queue" #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") self.driver.implicitly_wait(10) @@ -42,7 +42,7 @@ def test_checktext(self): self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() - self.driver.implicitly_wait(30) + self.driver.implicitly_wait(20) #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") # slurm_tab = self.driver.find_element_by_css_selector("li.p-mod-current:nth-child(2) > div:nth-child(2)") From 16eeeb19c0e6f4f27be98283ee904ca752b147c1 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 01:41:13 -0700 Subject: [PATCH 15/48] add try except --- tests/test_slurm.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 5fe6565..c3c76c9 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -50,15 +50,18 @@ def test_checktext(self): # assert slurm_tab.text == "Slurm Queue Manager" # jobid_text = self.driver.find_element(By.XPATH, "//div[contains(text(),'JOBID')]") - jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") - assert jobid_text.text == "JOBID" + try: + jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" - partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") - assert partition_text.text == "PARTITION" + partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - actions = ActionChains(self.driver) - actions.click(close_tab).perform() + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + actions = ActionChains(self.driver) + actions.click(close_tab).perform() + except NoSuchElementException: + print('No slurm elements found') if __name__ == '__main__': setup_method() From 5ff44855e8ceb734b77bbb3e9864d4058a76caab Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 01:48:09 -0700 Subject: [PATCH 16/48] add import exception --- tests/test_slurm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index c3c76c9..a6d8c00 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -8,6 +8,7 @@ from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.desired_capabilities import DesiredCapabilities +from selenium.common.exceptions import NoSuchElementExceptionxs class TestAddfavs(): def setup_method(self, method): From 8f4a361203c310bf81c1a87d6ad54230a43bff02 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 01:55:57 -0700 Subject: [PATCH 17/48] fix import --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index a6d8c00..fee5546 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -8,7 +8,7 @@ from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.desired_capabilities import DesiredCapabilities -from selenium.common.exceptions import NoSuchElementExceptionxs +from selenium.common.exceptions import NoSuchElementException class TestAddfavs(): def setup_method(self, method): From e54dbae5a5d5e423a5a3b8d8143fc24934409b24 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 02:11:29 -0700 Subject: [PATCH 18/48] contains text th --- tests/test_slurm.py | 52 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index fee5546..64efdc2 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -25,44 +25,42 @@ def test_checktext(self): self.driver.implicitly_wait(30) self.driver.maximize_window() self.driver.implicitly_wait(30) - #WebDriverWait(self.driver, 1000) -#div.jp-Launcher-section:nth-child(5) > div:nth-child(2) > div:nth-child(1) - - + #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" - #slurm_card = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - #slurm_card = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') - - # self.driver.implicitly_wait(10) #assert slurm_card.text == "Slurm Queue" - #slurm_card = driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + self.driver.implicitly_wait(10) - actions = ActionChains(self.driver) self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") + actions = ActionChains(self.driver) actions.click(slurm_card[1]).perform() - #actions.click(slurm_card).perform() - self.driver.implicitly_wait(20) + #actions.click(slurm_card[1]).perform() + self.driver.implicitly_wait(10) + + # try: + # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + # assert jobid_text.text == "JOBID" - #slurm_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[2]") - # slurm_tab = self.driver.find_element_by_css_selector("li.p-mod-current:nth-child(2) > div:nth-child(2)") - # slurm_tab = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue Manager')]") - # assert slurm_tab.text == "Slurm Queue Manager" + # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + # assert partition_text.text == "PARTITION" - # jobid_text = self.driver.find_element(By.XPATH, "//div[contains(text(),'JOBID')]") - try: - jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") - assert jobid_text.text == "JOBID" + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # actions = ActionChains(self.driver) + # actions.click(close_tab).perform() + # except NoSuchElementException: + # print('No slurm elements found') - partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") - assert partition_text.text == "PARTITION" + jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - actions = ActionChains(self.driver) - actions.click(close_tab).perform() - except NoSuchElementException: - print('No slurm elements found') + partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" + + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + actions = ActionChains(self.driver) + actions.click(close_tab).perform() if __name__ == '__main__': setup_method() From 93b98adcfe5e77b01a92d879b7312e533e665f8c Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 02:19:17 -0700 Subject: [PATCH 19/48] trial same page --- tests/test_slurm.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 64efdc2..9acee68 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -52,15 +52,18 @@ def test_checktext(self): # except NoSuchElementException: # print('No slurm elements found') - jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") - assert jobid_text.text == "JOBID" + jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") + assert jobid_text.text == "HPC Tools" - partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") - assert partition_text.text == "PARTITION" + # jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + # assert jobid_text.text == "JOBID" - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - actions = ActionChains(self.driver) - actions.click(close_tab).perform() + # partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + # assert partition_text.text == "PARTITION" + + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # actions = ActionChains(self.driver) + # actions.click(close_tab).perform() if __name__ == '__main__': setup_method() From e33fd36e84611c396848343038e4628f43b1cdd6 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 09:10:54 -0700 Subject: [PATCH 20/48] using slurm launcher --- tests/test_slurm.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 9acee68..9f78da0 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -24,19 +24,25 @@ def test_checktext(self): self.driver.get("http://localhost:8845/lab") self.driver.implicitly_wait(30) self.driver.maximize_window() - self.driver.implicitly_wait(30) + self.driver.implicitly_wait(20) #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" - slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') + #slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') + #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - - self.driver.implicitly_wait(10) - self.driver.execute_script("window.scrollTo(0,document.body.scrollHeight)") + console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") actions = ActionChains(self.driver) - actions.click(slurm_card[1]).perform() + actions.click(console).perform() + slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") + self.driver.implicitly_wait(10) + self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.click(slurm_card[1]).perform() + #actions.click(slurm_card).perform() + actions = ActionChains(self.driver) + actions.click(slurm_launcher).perform() self.driver.implicitly_wait(10) # try: @@ -52,18 +58,18 @@ def test_checktext(self): # except NoSuchElementException: # print('No slurm elements found') - jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") - assert jobid_text.text == "HPC Tools" + # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") + # assert jobid_text.text == "HPC Tools" - # jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") - # assert jobid_text.text == "JOBID" + jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" - # partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") - # assert partition_text.text == "PARTITION" + partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" - # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - # actions = ActionChains(self.driver) - # actions.click(close_tab).perform() + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + actions = ActionChains(self.driver) + actions.click(close_tab).perform() if __name__ == '__main__': setup_method() From c740d7ac700a5425ba3e85d0bf3012e1f9b10db3 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 09:54:58 -0700 Subject: [PATCH 21/48] run travis --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 9f78da0..73cd3a2 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -22,7 +22,7 @@ def test_checktext(self): #import pdb; pdb.set_trace() self.driver.get("http://localhost:8845/lab") - self.driver.implicitly_wait(30) + self.driver.implicitly_wait(10) self.driver.maximize_window() self.driver.implicitly_wait(20) From 096dcdd5fbdf7e34739150b83f81e8b4c91ddd9d Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 10:03:32 -0700 Subject: [PATCH 22/48] run travis 2 --- tests/test_slurm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 73cd3a2..f979e78 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -39,6 +39,7 @@ def test_checktext(self): #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(10) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) + self.driver.implicitly_wait(20) #actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() actions = ActionChains(self.driver) From 4b4a281a067c28f8d6cad590172863efcefcac0e Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Tue, 28 Jul 2020 10:12:27 -0700 Subject: [PATCH 23/48] run travis test --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index f979e78..4245caf 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -24,7 +24,7 @@ def test_checktext(self): self.driver.get("http://localhost:8845/lab") self.driver.implicitly_wait(10) self.driver.maximize_window() - self.driver.implicitly_wait(20) + self.driver.implicitly_wait(10) #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" From a61782e532ca575035486c722f92119f566c2045 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 29 Jul 2020 09:06:39 -0700 Subject: [PATCH 24/48] travis trial --- tests/test_slurm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 4245caf..8efdd18 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -32,8 +32,10 @@ def test_checktext(self): #slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') actions = ActionChains(self.driver) + self.driver.implicitly_wait(40) actions.click(console).perform() slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") @@ -43,6 +45,8 @@ def test_checktext(self): #actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() actions = ActionChains(self.driver) + #actions.move_to_element(slurm_launcher).perform() + #actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() self.driver.implicitly_wait(10) From eeb50204d724b0a441b6435fe791ab72a990b8dd Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 29 Jul 2020 09:13:19 -0700 Subject: [PATCH 25/48] travis local pass --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 8efdd18..963c512 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -40,8 +40,8 @@ def test_checktext(self): slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(10) - self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) - self.driver.implicitly_wait(20) + self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight+20);", slurm_launcher) + #self.driver.implicitly_wait(20) #actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() actions = ActionChains(self.driver) From 96839d4875510ea115aab7837937886a2faa46de Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 29 Jul 2020 09:31:11 -0700 Subject: [PATCH 26/48] travis trial 2 --- tests/test_slurm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 963c512..119c8b4 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -32,15 +32,15 @@ def test_checktext(self): #slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") - console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') + console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + #console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') actions = ActionChains(self.driver) self.driver.implicitly_wait(40) actions.click(console).perform() slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(10) - self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight+20);", slurm_launcher) + self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight+30);", slurm_launcher) #self.driver.implicitly_wait(20) #actions.click(slurm_card[1]).perform() #actions.click(slurm_card).perform() From 35470f412759f77795fb8346ec7ef2fba89ad18d Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 29 Jul 2020 10:19:46 -0700 Subject: [PATCH 27/48] travis trial 3 --- tests/test_slurm.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 119c8b4..b35c595 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -29,25 +29,27 @@ def test_checktext(self): #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" - #slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') + slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") #console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') - actions = ActionChains(self.driver) - self.driver.implicitly_wait(40) - actions.click(console).perform() - slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + + #self.driver.implicitly_wait(40) + #actions.click(console).perform() + #slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(10) - self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight+30);", slurm_launcher) + #self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_card) #self.driver.implicitly_wait(20) #actions.click(slurm_card[1]).perform() - #actions.click(slurm_card).perform() actions = ActionChains(self.driver) + actions.click(slurm_card[1]).perform() + #actions.click(slurm_card).perform() + #actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() #actions = ActionChains(self.driver) - actions.click(slurm_launcher).perform() + #actions.click(slurm_launcher).perform() self.driver.implicitly_wait(10) # try: From ef5fa4001e711b09c8f9424855b603b2257f2511 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 29 Jul 2020 11:04:59 -0700 Subject: [PATCH 28/48] travis trial 4 --- tests/test_slurm.py | 64 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index b35c595..647ad10 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -18,7 +18,7 @@ def setup_method(self, method): def teardown_method(self, method): self.driver.quit() - def test_checktext(self): + def test_slurmcard(self): #import pdb; pdb.set_trace() self.driver.get("http://localhost:8845/lab") @@ -32,13 +32,6 @@ def test_checktext(self): slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") - #console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') - - #self.driver.implicitly_wait(40) - #actions.click(console).perform() - #slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(10) #self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_card) #self.driver.implicitly_wait(20) @@ -78,7 +71,60 @@ def test_checktext(self): actions = ActionChains(self.driver) actions.click(close_tab).perform() + def test_slurmcommands(self): + #import pdb; pdb.set_trace() + + self.driver.get("http://localhost:8845/lab") + self.driver.implicitly_wait(10) + self.driver.maximize_window() + self.driver.implicitly_wait(10) + + #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') + self.driver.implicitly_wait(40) + actions = ActionChains(self.driver) + actions.click(console).perform() + slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") + self.driver.implicitly_wait(10) + self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) + + self.driver.implicitly_wait(10) + actions = ActionChains(self.driver) + + #actions.move_to_element(slurm_launcher).perform() + #actions = ActionChains(self.driver) + actions.click(slurm_launcher).perform() + self.driver.implicitly_wait(10) + + # try: + # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + # assert jobid_text.text == "JOBID" + + # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + # assert partition_text.text == "PARTITION" + + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # actions = ActionChains(self.driver) + # actions.click(close_tab).perform() + # except NoSuchElementException: + # print('No slurm elements found') + + # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") + # assert jobid_text.text == "HPC Tools" + + jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" + + partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" + + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + actions = ActionChains(self.driver) + actions.click(close_tab).perform() + if __name__ == '__main__': setup_method() - test_checktext() + test_slurmcard() + test_slurmcommands() teardown_method() \ No newline at end of file From d922e47f8b9691a915d10a80ed641a421198d630 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 01:20:01 -0700 Subject: [PATCH 29/48] update pytest --- tests/test_slurm.py | 100 +++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 647ad10..72f251c 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -22,9 +22,9 @@ def test_slurmcard(self): #import pdb; pdb.set_trace() self.driver.get("http://localhost:8845/lab") - self.driver.implicitly_wait(10) + self.driver.implicitly_wait(40) self.driver.maximize_window() - self.driver.implicitly_wait(10) + self.driver.implicitly_wait(40) #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") #assert card_text.text == "Slurm Queue" @@ -32,7 +32,7 @@ def test_slurmcard(self): slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") #assert slurm_card.text == "Slurm Queue" - self.driver.implicitly_wait(10) + self.driver.implicitly_wait(40) #self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_card) #self.driver.implicitly_wait(20) #actions.click(slurm_card[1]).perform() @@ -43,7 +43,7 @@ def test_slurmcard(self): #actions.move_to_element(slurm_launcher).perform() #actions = ActionChains(self.driver) #actions.click(slurm_launcher).perform() - self.driver.implicitly_wait(10) + self.driver.implicitly_wait(40) # try: # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") @@ -67,64 +67,70 @@ def test_slurmcard(self): partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") assert partition_text.text == "PARTITION" - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") + actions = ActionChains(self.driver) actions.click(close_tab).perform() - def test_slurmcommands(self): - #import pdb; pdb.set_trace() + # def test_slurmcommands(self): + # #import pdb; pdb.set_trace() - self.driver.get("http://localhost:8845/lab") - self.driver.implicitly_wait(10) - self.driver.maximize_window() - self.driver.implicitly_wait(10) + # self.driver.get("http://localhost:8845/lab") + # self.driver.implicitly_wait(40) + # self.driver.maximize_window() + # self.driver.implicitly_wait(40) - #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") - console = self.driver.find_element(By.XPATH, '//*[@title="Commands (⇧ ⌘ C)"]') - self.driver.implicitly_wait(40) - actions = ActionChains(self.driver) - actions.click(console).perform() - slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") - self.driver.implicitly_wait(10) - self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) - - self.driver.implicitly_wait(10) - actions = ActionChains(self.driver) + # #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + # console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') + # self.driver.implicitly_wait(40) + # actions = ActionChains(self.driver) + # actions.click(console).perform() + # slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + # #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") + # self.driver.implicitly_wait(40) + # self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) + # self.driver.implicitly_wait(40) + # actions = ActionChains(self.driver) - #actions.move_to_element(slurm_launcher).perform() - #actions = ActionChains(self.driver) - actions.click(slurm_launcher).perform() - self.driver.implicitly_wait(10) + # #actions.move_to_element(slurm_launcher).perform() + # #actions = ActionChains(self.driver) + # actions.click(slurm_launcher).perform() + # self.driver.implicitly_wait(40) - # try: - # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") - # assert jobid_text.text == "JOBID" + # # try: + # # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + # # assert jobid_text.text == "JOBID" - # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") - # assert partition_text.text == "PARTITION" + # # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + # # assert partition_text.text == "PARTITION" - # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - # actions = ActionChains(self.driver) - # actions.click(close_tab).perform() - # except NoSuchElementException: - # print('No slurm elements found') + # # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # # actions = ActionChains(self.driver) + # # actions.click(close_tab).perform() + # # except NoSuchElementException: + # # print('No slurm elements found') - # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") - # assert jobid_text.text == "HPC Tools" + # # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") + # # assert jobid_text.text == "HPC Tools" - jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") - assert jobid_text.text == "JOBID" + # jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + # assert jobid_text.text == "JOBID" - partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") - assert partition_text.text == "PARTITION" + # partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + # assert partition_text.text == "PARTITION" - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - actions = ActionChains(self.driver) - actions.click(close_tab).perform() + # self.driver.implicitly_wait(40) + + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # #close_tab = self.driver.find_element(By.XPATH, '//*[@data-icon-id="233519a9-a23c-4415-8e4f-961d69ab1b08"]') + + # actions = ActionChains(self.driver) + # actions.click(close_tab).perform() if __name__ == '__main__': setup_method() test_slurmcard() - test_slurmcommands() + # test_slurmcommands() teardown_method() \ No newline at end of file From c1e242d107fd676c17bc50345d97136be0ab0286 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 11:13:11 -0700 Subject: [PATCH 30/48] update pytest 2 --- tests/test_slurm.py | 145 ++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 72f251c..4a6800a 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -18,85 +18,31 @@ def setup_method(self, method): def teardown_method(self, method): self.driver.quit() - def test_slurmcard(self): - #import pdb; pdb.set_trace() - - self.driver.get("http://localhost:8845/lab") - self.driver.implicitly_wait(40) - self.driver.maximize_window() - self.driver.implicitly_wait(40) - - #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") - #assert card_text.text == "Slurm Queue" - - slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') - #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") - #assert slurm_card.text == "Slurm Queue" - self.driver.implicitly_wait(40) - #self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_card) - #self.driver.implicitly_wait(20) - #actions.click(slurm_card[1]).perform() - actions = ActionChains(self.driver) - actions.click(slurm_card[1]).perform() - #actions.click(slurm_card).perform() - #actions = ActionChains(self.driver) - #actions.move_to_element(slurm_launcher).perform() - #actions = ActionChains(self.driver) - #actions.click(slurm_launcher).perform() - self.driver.implicitly_wait(40) - - # try: - # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") - # assert jobid_text.text == "JOBID" - - # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") - # assert partition_text.text == "PARTITION" - - # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - # actions = ActionChains(self.driver) - # actions.click(close_tab).perform() - # except NoSuchElementException: - # print('No slurm elements found') - - # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") - # assert jobid_text.text == "HPC Tools" - - jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") - assert jobid_text.text == "JOBID" - - partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") - assert partition_text.text == "PARTITION" - - #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") - - actions = ActionChains(self.driver) - actions.click(close_tab).perform() - - # def test_slurmcommands(self): + # def test_slurmcard(self): # #import pdb; pdb.set_trace() # self.driver.get("http://localhost:8845/lab") # self.driver.implicitly_wait(40) # self.driver.maximize_window() # self.driver.implicitly_wait(40) - - # #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") - # console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') - # self.driver.implicitly_wait(40) - # actions = ActionChains(self.driver) - # actions.click(console).perform() - # slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - # #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") - # self.driver.implicitly_wait(40) - # self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) + + # #card_text = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/div[2]/div/div/div[5]/div[2]/div") + # #assert card_text.text == "Slurm Queue" + + # slurm_card = self.driver.find_elements_by_class_name('jp-NerscLaunchIcon') + # #slurm_card = self.driver.find_element_by_css_selector(".jp-NerscLaunchIcon.jp-Launcher-icon") + # #assert slurm_card.text == "Slurm Queue" # self.driver.implicitly_wait(40) + # #self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_card) + # #self.driver.implicitly_wait(20) + # #actions.click(slurm_card[1]).perform() # actions = ActionChains(self.driver) - + # actions.click(slurm_card[1]).perform() + # #actions.click(slurm_card).perform() + # #actions = ActionChains(self.driver) # #actions.move_to_element(slurm_launcher).perform() # #actions = ActionChains(self.driver) - # actions.click(slurm_launcher).perform() + # #actions.click(slurm_launcher).perform() # self.driver.implicitly_wait(40) # # try: @@ -121,14 +67,67 @@ def test_slurmcard(self): # partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") # assert partition_text.text == "PARTITION" - # self.driver.implicitly_wait(40) - - # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - # #close_tab = self.driver.find_element(By.XPATH, '//*[@data-icon-id="233519a9-a23c-4415-8e4f-961d69ab1b08"]') + # #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li/div[3]") # actions = ActionChains(self.driver) # actions.click(close_tab).perform() + def test_slurmcommands(self): + #import pdb; pdb.set_trace() + + self.driver.get("http://localhost:8845/lab") + self.driver.implicitly_wait(40) + self.driver.maximize_window() + self.driver.implicitly_wait(40) + + #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") + console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') + self.driver.implicitly_wait(40) + actions = ActionChains(self.driver) + actions.click(console).perform() + slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") + #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") + self.driver.implicitly_wait(40) + self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) + actions = ActionChains(self.driver) + #actions.move_to_element(slurm_launcher).perform() + self.driver.implicitly_wait(20) + actions.click(slurm_launcher).perform() + self.driver.implicitly_wait(40) + + # try: + # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") + # assert jobid_text.text == "JOBID" + + # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") + # assert partition_text.text == "PARTITION" + + # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + # actions = ActionChains(self.driver) + # actions.click(close_tab).perform() + # except NoSuchElementException: + # print('No slurm elements found') + + # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") + # assert jobid_text.text == "HPC Tools" + + jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") + assert jobid_text.text == "JOBID" + + partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") + assert partition_text.text == "PARTITION" + + self.driver.implicitly_wait(40) + + #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") + close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/ul/li/div[3]") + #close_tab = self.driver.find_element(By.XPATH, '//*[@data-icon-id="233519a9-a23c-4415-8e4f-961d69ab1b08"]') + + actions = ActionChains(self.driver) + actions.click(close_tab).perform() + if __name__ == '__main__': setup_method() test_slurmcard() From 2faba34df5f797126cbe8eb12ea56f67dbb0c9be Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 11:25:12 -0700 Subject: [PATCH 31/48] update pytest 3 --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 4a6800a..84f724d 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -93,7 +93,7 @@ def test_slurmcommands(self): self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(20) + self.driver.implicitly_wait(40) actions.click(slurm_launcher).perform() self.driver.implicitly_wait(40) From 17244460b8705e8025c8568db9b6d93c1e28432e Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 11:36:24 -0700 Subject: [PATCH 32/48] update pytest 4 --- tests/test_slurm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 84f724d..e6cb110 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -87,8 +87,10 @@ def test_slurmcommands(self): self.driver.implicitly_wait(40) actions = ActionChains(self.driver) actions.click(console).perform() + self.driver.implicitly_wait(40) slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #slurm_launcher = self.driver.find_element_by_css_selector("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") + #slurm_launcher = self.driver.find_element_by_css_selector + #("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") self.driver.implicitly_wait(40) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) From 227ed68b2ed4a4c3ea0c7d1f3de72ce013c961c9 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 11:50:45 -0700 Subject: [PATCH 33/48] update pytest 5 --- tests/test_slurm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index e6cb110..f47098c 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -124,11 +124,11 @@ def test_slurmcommands(self): self.driver.implicitly_wait(40) #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/ul/li/div[3]") + #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/ul/li/div[3]") #close_tab = self.driver.find_element(By.XPATH, '//*[@data-icon-id="233519a9-a23c-4415-8e4f-961d69ab1b08"]') - actions = ActionChains(self.driver) - actions.click(close_tab).perform() + #actions = ActionChains(self.driver) + #actions.click(close_tab).perform() if __name__ == '__main__': setup_method() From 0f1500be279588536c870ae57352dfac7627ac8e Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 11:59:02 -0700 Subject: [PATCH 34/48] update pytest 6 --- tests/test_slurm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index f47098c..bd21adc 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -95,7 +95,7 @@ def test_slurmcommands(self): self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(40) + self.driver.implicitly_wait(50) actions.click(slurm_launcher).perform() self.driver.implicitly_wait(40) @@ -132,6 +132,6 @@ def test_slurmcommands(self): if __name__ == '__main__': setup_method() - test_slurmcard() - # test_slurmcommands() + #test_slurmcard() + test_slurmcommands() teardown_method() \ No newline at end of file From 3cbd1837857af538c4b002051211442e7c8ca420 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 22:02:24 -0700 Subject: [PATCH 35/48] removing waits --- tests/test_slurm.py | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index bd21adc..4d9bdc6 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -81,54 +81,28 @@ def test_slurmcommands(self): self.driver.implicitly_wait(40) self.driver.maximize_window() self.driver.implicitly_wait(40) - - #console = self.driver.find_element_by_css_selector("li.p-TabBar-tab:nth-child(3)") console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') - self.driver.implicitly_wait(40) + #self.driver.implicitly_wait(40) actions = ActionChains(self.driver) actions.click(console).perform() - self.driver.implicitly_wait(40) + #self.driver.implicitly_wait(40) slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #slurm_launcher = self.driver.find_element_by_css_selector - #("li.p-CommandPalette-item:nth-child(31) > div:nth-child(2) > div:nth-child(1)") - self.driver.implicitly_wait(40) + #self.driver.implicitly_wait(40) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(50) + #self.driver.implicitly_wait(50) actions.click(slurm_launcher).perform() - self.driver.implicitly_wait(40) - - # try: - # jobid_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'JOBID')]") - # assert jobid_text.text == "JOBID" - - # partition_text = self.driver.find_element(By.XPATH, "//*[contains(text(),'PARTITION')]") - # assert partition_text.text == "PARTITION" - - # close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - # actions = ActionChains(self.driver) - # actions.click(close_tab).perform() - # except NoSuchElementException: - # print('No slurm elements found') - - # jobid_text = self.driver.find_element(By.XPATH, "//h2[contains(text(),'HPC Tools')]") - # assert jobid_text.text == "HPC Tools" - + #self.driver.implicitly_wait(40) jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") assert jobid_text.text == "JOBID" partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") assert partition_text.text == "PARTITION" - self.driver.implicitly_wait(40) + #self.driver.implicitly_wait(40) + - #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[2]/ul/li[2]/div[3]") - #close_tab = self.driver.find_element(By.XPATH, "/html/body/div/div[3]/div[2]/div[3]/div[3]/ul/li/div[3]") - #close_tab = self.driver.find_element(By.XPATH, '//*[@data-icon-id="233519a9-a23c-4415-8e4f-961d69ab1b08"]') - - #actions = ActionChains(self.driver) - #actions.click(close_tab).perform() if __name__ == '__main__': setup_method() From d1ccd9837d9fe815fb33718e99bc9251903f5e1c Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 22:19:06 -0700 Subject: [PATCH 36/48] adding waits --- tests/test_slurm.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 4d9bdc6..46cb3b3 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -82,25 +82,25 @@ def test_slurmcommands(self): self.driver.maximize_window() self.driver.implicitly_wait(40) console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') - #self.driver.implicitly_wait(40) + self.driver.implicitly_wait(40) actions = ActionChains(self.driver) actions.click(console).perform() - #self.driver.implicitly_wait(40) + self.driver.implicitly_wait(40) slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - #self.driver.implicitly_wait(40) + self.driver.implicitly_wait(40) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - #self.driver.implicitly_wait(50) + self.driver.implicitly_wait(50) actions.click(slurm_launcher).perform() - #self.driver.implicitly_wait(40) + self.driver.implicitly_wait(40) jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") assert jobid_text.text == "JOBID" partition_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'PARTITION')]") assert partition_text.text == "PARTITION" - #self.driver.implicitly_wait(40) + self.driver.implicitly_wait(40) From 7e28fda8d34e356aae364317a74b2cf714e8bf5d Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 22:29:11 -0700 Subject: [PATCH 37/48] edit pytest --- tests/test_slurm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 46cb3b3..5e258d7 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -91,8 +91,9 @@ def test_slurmcommands(self): self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(50) + self.driver.implicitly_wait(40) actions.click(slurm_launcher).perform() + self.driver.implicitly_wait(40) jobid_text = self.driver.find_element(By.XPATH, "//th[contains(text(),'JOBID')]") assert jobid_text.text == "JOBID" From 892122b8a2a16486e3b0a587a306de960a07d33d Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 22:40:41 -0700 Subject: [PATCH 38/48] edit pytest 2 --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 5e258d7..60a1cd0 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -89,9 +89,9 @@ def test_slurmcommands(self): slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") self.driver.implicitly_wait(40) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) - actions = ActionChains(self.driver) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(40) + self.driver.implicitly_wait(50) + actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() self.driver.implicitly_wait(40) From 01272ab038a5a74ee2bdfdf2f3b9af83532fbe39 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 23:04:45 -0700 Subject: [PATCH 39/48] edit pytest 3 --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 60a1cd0..ebc3a81 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -87,10 +87,10 @@ def test_slurmcommands(self): actions.click(console).perform() self.driver.implicitly_wait(40) slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - self.driver.implicitly_wait(40) + self.driver.implicitly_wait(50) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(50) + self.driver.implicitly_wait(60) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From 58853d4bc25ca473b3acc76541007ebe164b114a Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Thu, 30 Jul 2020 23:53:38 -0700 Subject: [PATCH 40/48] edit pytest 4 --- tests/test_slurm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index ebc3a81..311681b 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -87,10 +87,10 @@ def test_slurmcommands(self): actions.click(console).perform() self.driver.implicitly_wait(40) slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") - self.driver.implicitly_wait(50) + self.driver.implicitly_wait(20) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(60) + self.driver.implicitly_wait(20) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From 556ab5688fe3bc3ee984a4cd25a5879e6307e445 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 31 Jul 2020 03:39:38 -0700 Subject: [PATCH 41/48] edit pytest 5 --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index 311681b..bfadb90 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -82,7 +82,7 @@ def test_slurmcommands(self): self.driver.maximize_window() self.driver.implicitly_wait(40) console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') - self.driver.implicitly_wait(40) + self.driver.implicitly_wait(30) actions = ActionChains(self.driver) actions.click(console).perform() self.driver.implicitly_wait(40) From 0778a24fc47cb539a4e18509ae2cba80cb8becf7 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 31 Jul 2020 03:48:07 -0700 Subject: [PATCH 42/48] edit pytest 6 --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index bfadb90..ddf8ee6 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -90,7 +90,7 @@ def test_slurmcommands(self): self.driver.implicitly_wait(20) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(20) + self.driver.implicitly_wait(60) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From 9d7984691006defcab70329c24ab0a33ebde01c4 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 31 Jul 2020 10:31:43 -0700 Subject: [PATCH 43/48] edit pytest 7 --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index ddf8ee6..df01eff 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -90,7 +90,7 @@ def test_slurmcommands(self): self.driver.implicitly_wait(20) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(60) + self.driver.implicitly_wait(30) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From df62cf106607682f0784ec3c1c89199f6019131d Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 31 Jul 2020 10:48:05 -0700 Subject: [PATCH 44/48] edit pytest 8 --- tests/test_slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index df01eff..bfadb90 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -90,7 +90,7 @@ def test_slurmcommands(self): self.driver.implicitly_wait(20) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(30) + self.driver.implicitly_wait(20) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From d05d0df8fe2e3ad4dc608e78bced2b2330b501f5 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 31 Jul 2020 10:56:43 -0700 Subject: [PATCH 45/48] edit pytest 9 --- tests/test_slurm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_slurm.py b/tests/test_slurm.py index bfadb90..6e5f904 100644 --- a/tests/test_slurm.py +++ b/tests/test_slurm.py @@ -81,16 +81,18 @@ def test_slurmcommands(self): self.driver.implicitly_wait(40) self.driver.maximize_window() self.driver.implicitly_wait(40) + console = self.driver.find_element(By.XPATH, '//*[@data-id="command-palette"]') self.driver.implicitly_wait(30) actions = ActionChains(self.driver) actions.click(console).perform() self.driver.implicitly_wait(40) + slurm_launcher = self.driver.find_element(By.XPATH, "//div[contains(text(),'Slurm Queue')]") self.driver.implicitly_wait(20) self.driver.execute_script("return arguments[0].scrollIntoView(0, document.documentElement.scrollHeight-10);", slurm_launcher) #actions.move_to_element(slurm_launcher).perform() - self.driver.implicitly_wait(20) + self.driver.implicitly_wait(60) actions = ActionChains(self.driver) actions.click(slurm_launcher).perform() From 330b11054b356089cb955b97a95c1062cea0fade Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 7 Aug 2020 11:06:29 -0700 Subject: [PATCH 46/48] add api tests --- .travis.yml | 2 ++ infinite.txt | 6 ++++ jupyterlab_slurm/slurm.py | 1 + jupyterlab_slurm/test-api.py | 61 ++++++++++++++++++++++++++++++++++++ sq_output.txt | 1 + squeue | 3 ++ tests/sbatch | 2 ++ tests/scancel | 1 + tests/scontrol | 1 + tests/squeue | 3 ++ 10 files changed, 81 insertions(+) create mode 100644 infinite.txt create mode 100644 jupyterlab_slurm/test-api.py create mode 100644 sq_output.txt create mode 100755 squeue create mode 100644 tests/sbatch create mode 100644 tests/scancel create mode 100644 tests/scontrol create mode 100755 tests/squeue diff --git a/.travis.yml b/.travis.yml index 036d031..1fb9b3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,8 +44,10 @@ install: script: + - JUPYTER_TOKEN=secret jupyter-notebook & - jupyter labextension list - jupyter lab --port=8845 --NotebookApp.token='' & + - export PATH=$(pwd)/tests:$PATH - sleep 30 - pytest diff --git a/infinite.txt b/infinite.txt new file mode 100644 index 0000000..f3a3bbd --- /dev/null +++ b/infinite.txt @@ -0,0 +1,6 @@ +#!/bin/sh +#SBATCH -C haswell +while [ ! -f /global/ul/n/labanyam/stop] +do + sleep 3000 +done \ No newline at end of file diff --git a/jupyterlab_slurm/slurm.py b/jupyterlab_slurm/slurm.py index 5ee0c80..f37927b 100755 --- a/jupyterlab_slurm/slurm.py +++ b/jupyterlab_slurm/slurm.py @@ -16,6 +16,7 @@ class ShellExecutionHandler(IPythonHandler): async def run_command(self, command, stdin=None, cwd=None): + print(command) commands = shlex.split(command) process = await asyncio.create_subprocess_exec(*commands, stdout=asyncio.subprocess.PIPE, diff --git a/jupyterlab_slurm/test-api.py b/jupyterlab_slurm/test-api.py new file mode 100644 index 0000000..a954959 --- /dev/null +++ b/jupyterlab_slurm/test-api.py @@ -0,0 +1,61 @@ +#http://localhost:8845/ +import requests +import pytest +import asyncio +import json +import os +from http.client import HTTPConnection +from urllib.parse import quote +from tornado.websocket import websocket_connect + + +# def test_get_request(): +# r = requests.get('http://localhost:8845/') +# print(r.text) +# print("----------------") +# print(r.headers['Content-Type']) +# print("----------------") +# print(r.json()) + +PORT = os.getenv('TEST_PORT', 8845) +TOKEN = os.getenv('JUPYTER_TOKEN', 'secret') + + +def request_get(port, path, token, host='localhost'): + h = HTTPConnection(host, port, 10) + if '?' in path: + url = '{}&token={}'.format(path, token) + + else: + url = '{}?token={}'.format(path, token) + h.request('GET', url) + return h.getresponse() + +def test_sbatch(): + r = request_get(PORT, '/sbatch?inputType=contents', TOKEN) + #print(dir(r)) + print(r.read) + assert r.code == 200 + #response = (json.loads(r.read().decode("utf-8"))) + #print(response["data"]) + + +def test_squeue(): + jobID = [] + r = request_get(PORT, '/squeue?userOnly=true', TOKEN) + response = (json.loads(r.read().decode("utf-8"))) + print(response["data"]) + jobID += response["data"] + assert r.code == 200 + +# def test_scontrol(): +# r = request_get(PORT, '/scontrol', TOKEN) +# assert r.code == 200 + +# def test_scancel(): +# r = request_get(PORT, '/scancel', TOKEN) + + +if __name__ == '__main__': + test_sbatch() + test_squeue() \ No newline at end of file diff --git a/sq_output.txt b/sq_output.txt new file mode 100644 index 0000000..dd3825e --- /dev/null +++ b/sq_output.txt @@ -0,0 +1 @@ +JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) diff --git a/squeue b/squeue new file mode 100755 index 0000000..4b604f3 --- /dev/null +++ b/squeue @@ -0,0 +1,3 @@ +#!/bin/sh +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cat $DIR/sq_output.txt \ No newline at end of file diff --git a/tests/sbatch b/tests/sbatch new file mode 100644 index 0000000..544cd2e --- /dev/null +++ b/tests/sbatch @@ -0,0 +1,2 @@ +#!/bin/sh +echo "1000000" diff --git a/tests/scancel b/tests/scancel new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/tests/scancel @@ -0,0 +1 @@ +#!/bin/sh diff --git a/tests/scontrol b/tests/scontrol new file mode 100644 index 0000000..96b4b06 --- /dev/null +++ b/tests/scontrol @@ -0,0 +1 @@ +#!/bin/sh \ No newline at end of file diff --git a/tests/squeue b/tests/squeue new file mode 100755 index 0000000..e9d4f2a --- /dev/null +++ b/tests/squeue @@ -0,0 +1,3 @@ +#!/bin/sh +echo " 33241147 debug_hsw infinite labanyam R 2:25 1 nid01172" + \ No newline at end of file From 90be50dc3367ee013a1d5a69cf065105baaf5842 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Wed, 12 Aug 2020 22:25:53 -0700 Subject: [PATCH 47/48] add slurm api tests --- jupyterlab_slurm/slurm.py | 5 +++- jupyterlab_slurm/test-api.py | 52 +++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/jupyterlab_slurm/slurm.py b/jupyterlab_slurm/slurm.py index f37927b..f532917 100755 --- a/jupyterlab_slurm/slurm.py +++ b/jupyterlab_slurm/slurm.py @@ -102,9 +102,12 @@ async def post(self): # Have two options to specify SLURM script in the request body: either with a path to the script, or with the script's text contents if inputType: if inputType == 'path': + print(self.request.body) + print(self.request.headers['Content-Type'] == 'application/json') if self.request.headers['Content-Type'] == 'application/json': script_path = json.loads(self.request.body)["input"] else: + print("shouldn't be here") script_path = self.get_body_argument('input') try: stdout, stderr, returncode = await self.run_command(sbatch_command + script_path, cwd=outputDir) @@ -122,7 +125,7 @@ async def post(self): temp.flush() temp.seek(0) try: - stdout, stderr, returncode = await self.run_command(sbatch_command, stdin=temp.fileno(), cwd=outputDir) + stdout, stderr, returncode = await self.run_command(sbatch_csrfommand, stdin=temp.fileno(), cwd=outputDir) errorMessage = "" except Exception as e: stdout, stderr, returncode, errorMessage = ( diff --git a/jupyterlab_slurm/test-api.py b/jupyterlab_slurm/test-api.py index a954959..c4b0b40 100644 --- a/jupyterlab_slurm/test-api.py +++ b/jupyterlab_slurm/test-api.py @@ -31,29 +31,61 @@ def request_get(port, path, token, host='localhost'): h.request('GET', url) return h.getresponse() +# def request_post(port, path, token, host='localhost'): +# h = HTTPConnection(host, port, 10) +# if '?' in path: +# url = '{}&token={}'.format(path, token) + +# else: +# url = '{}?token={}'.format(path, token) +# params = urllib.parse.urlencode({"input":"#!/bin/sh"}) +# headers = {"Content-type": "application/json", +# ... "Accept": "*/*"} +# h.request('POST', url) +# return h.getresponse() + +def request_delete(port, path, token, host='localhost'): + h = HTTPConnection(host, port, 10) + if '?' in path: + url = '{}&token={}'.format(path, token) + + else: + url = '{}?token={}'.format(path, token) + h.request('DELETE', url) + return h.getresponse() + + def test_sbatch(): - r = request_get(PORT, '/sbatch?inputType=contents', TOKEN) + #r = request_post(PORT, '/sbatch?inputType=path', TOKEN) + r = requests.post('http://localhost:8845/sbatch?inputType=contents&outputDir=~%2FDesktop%2Fjupyterlab-slurm%2F&token='+TOKEN, data = '{"input":"#!/bin/sh"}', headers={"content-type": "application/json"} ) #print(dir(r)) - print(r.read) - assert r.code == 200 + #print(r.msg) + print(r.text) + assert r.status_code == 200 #response = (json.loads(r.read().decode("utf-8"))) #print(response["data"]) def test_squeue(): jobID = [] - r = request_get(PORT, '/squeue?userOnly=true', TOKEN) - response = (json.loads(r.read().decode("utf-8"))) - print(response["data"]) - jobID += response["data"] - assert r.code == 200 + r = requests.get('http://localhost:8845/squeue?userOnly=true&token='+ TOKEN) + #r = request_get(PORT, '/squeue?userOnly=true', TOKEN) + # response = (json.loads(r.read().decode("utf-8"))) + # print(response["data"]) + # jobID += response["data"] + assert r.status_code == 200 # def test_scontrol(): # r = request_get(PORT, '/scontrol', TOKEN) # assert r.code == 200 -# def test_scancel(): -# r = request_get(PORT, '/scancel', TOKEN) +def test_scancel(): + + #r = request_get(PORT, '/scancel', TOKEN) + r = requests.delete('http://localhost:8845/scancel?token=' + TOKEN, data = json.dumps({ "jobID": '33241147' }), headers={"content-type": "application/json"}) + #print(r.read) + print(r.text) + assert r.status_code == 200 if __name__ == '__main__': From 3cf8172e149ad809fee13daed7c153a504f379f7 Mon Sep 17 00:00:00 2001 From: Labanya Mukhopadhyay Date: Fri, 14 Aug 2020 19:15:20 -0700 Subject: [PATCH 48/48] update api tests --- .travis.yml | 1 + jupyterlab_slurm/slurm.py | 2 +- jupyterlab_slurm/test-api.py | 93 ------------------------------------ tests/sbatch | 2 +- tests/scancel | 1 + tests/scontrol | 3 +- tests/test-api.py | 53 ++++++++++++++++++++ 7 files changed, 59 insertions(+), 96 deletions(-) delete mode 100644 jupyterlab_slurm/test-api.py mode change 100644 => 100755 tests/sbatch mode change 100644 => 100755 tests/scancel mode change 100644 => 100755 tests/scontrol create mode 100644 tests/test-api.py diff --git a/.travis.yml b/.travis.yml index 1fb9b3f..3473c47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,3 +51,4 @@ script: - sleep 30 - pytest +# JUPYTER_TOKEN=secret jupyter lab --port=8845 --NotebookApp.token='' & \ No newline at end of file diff --git a/jupyterlab_slurm/slurm.py b/jupyterlab_slurm/slurm.py index f532917..27897c7 100755 --- a/jupyterlab_slurm/slurm.py +++ b/jupyterlab_slurm/slurm.py @@ -125,7 +125,7 @@ async def post(self): temp.flush() temp.seek(0) try: - stdout, stderr, returncode = await self.run_command(sbatch_csrfommand, stdin=temp.fileno(), cwd=outputDir) + stdout, stderr, returncode = await self.run_command(sbatch_command, stdin=temp.fileno(), cwd=outputDir) errorMessage = "" except Exception as e: stdout, stderr, returncode, errorMessage = ( diff --git a/jupyterlab_slurm/test-api.py b/jupyterlab_slurm/test-api.py deleted file mode 100644 index c4b0b40..0000000 --- a/jupyterlab_slurm/test-api.py +++ /dev/null @@ -1,93 +0,0 @@ -#http://localhost:8845/ -import requests -import pytest -import asyncio -import json -import os -from http.client import HTTPConnection -from urllib.parse import quote -from tornado.websocket import websocket_connect - - -# def test_get_request(): -# r = requests.get('http://localhost:8845/') -# print(r.text) -# print("----------------") -# print(r.headers['Content-Type']) -# print("----------------") -# print(r.json()) - -PORT = os.getenv('TEST_PORT', 8845) -TOKEN = os.getenv('JUPYTER_TOKEN', 'secret') - - -def request_get(port, path, token, host='localhost'): - h = HTTPConnection(host, port, 10) - if '?' in path: - url = '{}&token={}'.format(path, token) - - else: - url = '{}?token={}'.format(path, token) - h.request('GET', url) - return h.getresponse() - -# def request_post(port, path, token, host='localhost'): -# h = HTTPConnection(host, port, 10) -# if '?' in path: -# url = '{}&token={}'.format(path, token) - -# else: -# url = '{}?token={}'.format(path, token) -# params = urllib.parse.urlencode({"input":"#!/bin/sh"}) -# headers = {"Content-type": "application/json", -# ... "Accept": "*/*"} -# h.request('POST', url) -# return h.getresponse() - -def request_delete(port, path, token, host='localhost'): - h = HTTPConnection(host, port, 10) - if '?' in path: - url = '{}&token={}'.format(path, token) - - else: - url = '{}?token={}'.format(path, token) - h.request('DELETE', url) - return h.getresponse() - - -def test_sbatch(): - #r = request_post(PORT, '/sbatch?inputType=path', TOKEN) - r = requests.post('http://localhost:8845/sbatch?inputType=contents&outputDir=~%2FDesktop%2Fjupyterlab-slurm%2F&token='+TOKEN, data = '{"input":"#!/bin/sh"}', headers={"content-type": "application/json"} ) - #print(dir(r)) - #print(r.msg) - print(r.text) - assert r.status_code == 200 - #response = (json.loads(r.read().decode("utf-8"))) - #print(response["data"]) - - -def test_squeue(): - jobID = [] - r = requests.get('http://localhost:8845/squeue?userOnly=true&token='+ TOKEN) - #r = request_get(PORT, '/squeue?userOnly=true', TOKEN) - # response = (json.loads(r.read().decode("utf-8"))) - # print(response["data"]) - # jobID += response["data"] - assert r.status_code == 200 - -# def test_scontrol(): -# r = request_get(PORT, '/scontrol', TOKEN) -# assert r.code == 200 - -def test_scancel(): - - #r = request_get(PORT, '/scancel', TOKEN) - r = requests.delete('http://localhost:8845/scancel?token=' + TOKEN, data = json.dumps({ "jobID": '33241147' }), headers={"content-type": "application/json"}) - #print(r.read) - print(r.text) - assert r.status_code == 200 - - -if __name__ == '__main__': - test_sbatch() - test_squeue() \ No newline at end of file diff --git a/tests/sbatch b/tests/sbatch old mode 100644 new mode 100755 index 544cd2e..ca29678 --- a/tests/sbatch +++ b/tests/sbatch @@ -1,2 +1,2 @@ #!/bin/sh -echo "1000000" +echo "Success: Submitted batch job 33241147" diff --git a/tests/scancel b/tests/scancel old mode 100644 new mode 100755 index 1a24852..754da39 --- a/tests/scancel +++ b/tests/scancel @@ -1 +1,2 @@ #!/bin/sh +echo "Success: scancel 33241147" \ No newline at end of file diff --git a/tests/scontrol b/tests/scontrol old mode 100644 new mode 100755 index 96b4b06..2d79e08 --- a/tests/scontrol +++ b/tests/scontrol @@ -1 +1,2 @@ -#!/bin/sh \ No newline at end of file +#!/bin/sh +echo "Success: scontrol hold 33241147" \ No newline at end of file diff --git a/tests/test-api.py b/tests/test-api.py new file mode 100644 index 0000000..87b6f6c --- /dev/null +++ b/tests/test-api.py @@ -0,0 +1,53 @@ +#http://localhost:8845/ +import requests +import pytest +import asyncio +import json +import os +from http.client import HTTPConnection +from urllib.parse import quote +from tornado.websocket import websocket_connect + + +PORT = os.getenv('TEST_PORT', 8845) +TOKEN = os.getenv('JUPYTER_TOKEN', 'secret') + + +def test_sbatch(): + r = requests.post('http://localhost:8845/sbatch?inputType=contents&outputDir=%2Ftmp&token='+TOKEN, data = '{"input":"#!/bin/sh"}', headers={"content-type": "application/json"} ) + assert r.status_code == 200 + + fail_r = requests.post('http://localhost:8845/sbatch?inputType=contents&outputDir=%2Ftmp&token='+TOKEN, headers={"content-type": "application/json"} ) + assert fail_r.status_code != 200 + +def test_squeue(): + jobID = [] + r = requests.get('http://localhost:8845/squeue?userOnly=true&token='+ TOKEN) + assert r.status_code == 200 + assert len(r.json()['data'][0]) == 8 + + fail_r = requests.get('http://localhost:8845/squeue&token='+ TOKEN) + print(fail_r.text) + assert fail_r.status_code != 200 + + +def test_scontrol(): + r = requests.patch('http://localhost:8845/scontrol/hold?token='+ TOKEN, data = json.dumps({ "jobID": '33241147' }), headers={"content-type": "application/json"}) + assert r.status_code == 200 + assert ("Success: scontrol hold") in r.json()['responseMessage'] + + fail_r = requests.patch('http://localhost:8845/scontrol/hold?token='+ TOKEN, headers={"content-type": "application/json"}) + assert fail_r.status_code != 200 + + +def test_scancel(): + r = requests.delete('http://localhost:8845/scancel?token=' + TOKEN, data = json.dumps({ "jobID": '33241147' }), headers={"content-type": "application/json"}) + assert r.status_code == 200 + assert ("Success: scancel") in r.json()['responseMessage'] + + fail_r = requests.delete('http://localhost:8845/scancel?token=' + TOKEN, data = json.dumps({ "jobID": '33241147' })) + assert fail_r.status_code != 200 + +if __name__ == '__main__': + test_sbatch() + test_squeue() \ No newline at end of file