Skip to content

Commit 1068575

Browse files
authored
test: run UI tests without Saucelabs (#405)
* test: run UI tests without Saucelabs * ci: use proper path to geckodriver * ci: actually install poetry * ci: install pytest-rerunfailures and use correct matrix variable
1 parent 53d3bc5 commit 1068575

File tree

10 files changed

+58
-254
lines changed

10 files changed

+58
-254
lines changed

.github/workflows/build-test-release.yaml

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ jobs:
7171
runs-on: ubuntu-latest
7272
steps:
7373
- uses: actions/checkout@v4
74-
with:
75-
submodules: true
7674
- uses: actions/setup-python@v4
7775
with:
78-
python-version: 3.7
76+
python-version: "3.7"
7977
- run: |
8078
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
8179
- run: |
@@ -106,17 +104,14 @@ jobs:
106104
--source=tests/testdata/Splunk_TA_UCCExample/package \
107105
--config=tests/testdata/Splunk_TA_UCCExample/globalConfig.json \
108106
--ta-version=0.0.1
109-
- uses: actions/upload-artifact@v3
110-
with:
111-
name: package
112-
path: dist/*
113107
if: always()
114108
- uses: actions/upload-artifact@v3
115109
with:
116110
name: output
117111
path: output/*
118112

119113
run-ui-tests:
114+
name: test-ui Splunk ${{ matrix.splunk.version }} -k ${{ matrix.test_suite }}
120115
needs:
121116
- meta
122117
- build
@@ -145,69 +140,26 @@ jobs:
145140
]
146141
steps:
147142
- uses: actions/checkout@v4
143+
- uses: actions/setup-python@v4
148144
with:
149-
submodules: recursive
150-
- uses: actions/download-artifact@v3
151-
with:
152-
name: package
153-
path: dist/
145+
python-version: "3.7"
154146
- uses: actions/download-artifact@v3
155147
with:
156148
name: output
157149
path: output/
158-
- run: |
159-
git submodule sync
160-
git submodule update --recursive --remote
161-
- name: Splunk Testing
150+
- run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
151+
- run: poetry install
152+
- name: Link chromedriver and geckodriver
153+
# Use installed chromedriver https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
162154
run: |
163-
mkdir test-results
164-
export SPLUNK_VERSION=${{ matrix.splunk.version }}
165-
SPLUNK_APP_ID=Splunk_TA_UCCExample
166-
export SPLUNK_APP_ID
167-
SPLUNK_APP_PACKAGE=output/Splunk_TA_UCCExample
168-
export SPLUNK_APP_PACKAGE
169-
export TEST_SET=tests/ui
170-
export TEST_BROWSER="${{ matrix.browser }}"
171-
export TEST_SUITE="-k ${{ matrix.test_suite }}"
172-
export SAUCE_USERNAME="${{ secrets.SAUCE_USERNAME }}"
173-
export SAUCE_PASSWORD="${{ secrets.SAUCE_PASSWORD }}"
174-
export SAUCE_TUNNEL_ID="${{ secrets.SAUCE_TUNNEL_ID }}"
175-
JOB_NAME="GithubActions::${GITHUB_REPOSITORY#splunk/}[${GITHUB_REF#refs/heads/}][${{ matrix.browser }}] #$(date +%s)"
176-
export JOB_NAME
177-
SAUCE_IDENTIFIER=$SAUCE_IDENTIFIER-$(cat /proc/sys/kernel/random/uuid)
178-
export SAUCE_IDENTIFIER
179-
echo "environment setup..."
180-
echo "$SPLUNK_VERSION"
181-
echo "$SPLUNK_APP_ID"
182-
echo "$SPLUNK_APP_PACKAGE"
183-
echo "$TEST_SET"
184-
echo "$TEST_BROWSER"
185-
echo "$TEST_SUITE"
186-
echo "Testing..."
187-
docker-compose -f docker-compose-ci.yml build
188-
# Saucelab connection
189-
docker-compose -f docker-compose-ci.yml up -d sauceconnect
190-
191-
# Start Splunk
192-
docker-compose -f docker-compose-ci.yml up -d splunk
193-
until docker-compose -f docker-compose-ci.yml logs splunk | grep "Ansible playbook complete" ; do sleep 1; done
194-
# Normal Inspecting
195-
docker-compose -f docker-compose-ci.yml logs sauceconnect
196-
docker ps -a
197-
# Run the tests
198-
test_exit_code=0
199-
docker-compose -f docker-compose-ci.yml up --abort-on-container-exit test || test_exit_code=$?
200-
# Collect Results
201-
docker container create --name dummy \
202-
-v addon-factory-smartx-ui-test-library_results:/work/test-results \
203-
registry.access.redhat.com/ubi7/ubi
204-
docker cp dummy:/work/test-results/test.xml test-results/ || true
205-
docker cp dummy:/work/test-results/test.xml test-results/ || true
206-
docker cp dummy:/work/assets test-results/assets || true
207-
docker cp dummy:/work/test-results/report.html test-results/report.html || true
208-
docker-compose -f docker-compose-ci.yml down || true
209-
echo exit code "$test_exit_code"
210-
exit "$test_exit_code"
155+
export PATH=$PATH:$CHROMEWEBDRIVER
156+
chromedriver --version
157+
export PATH=$PATH:$GECKOWEBDRIVER
158+
geckodriver --version
159+
- run: |
160+
./run_splunk.sh ${{ matrix.splunk.version }}
161+
until curl -Lsk "https://localhost:8088/services/collector/health" &>/dev/null ; do echo -n "Waiting for HEC-" && sleep 5 ; done
162+
- run: poetry run pytest tests/ui -k "${{ matrix.test_suite }}" --headless --junitxml=test-results/junit.xml
211163
- uses: actions/upload-artifact@v3
212164
if: always()
213165
with:

Dockerfile-splunk

Lines changed: 0 additions & 23 deletions
This file was deleted.

Dockerfile-tests

Lines changed: 0 additions & 41 deletions
This file was deleted.

docker-compose-ci.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

poetry.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Sphinx = "*"
5252
sphinx_rtd_theme = "*"
5353
sphinx-panels = "*"
5454
splunk-add-on-ucc-framework = "^5.28.5"
55+
pytest-rerunfailures = "^12.0"
5556

5657
[build-system]
5758
requires = ["poetry_core>=1.0.0"]

pytest.ini

Lines changed: 0 additions & 25 deletions
This file was deleted.

Dockerfile-saucelabs renamed to run_splunk.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
FROM circleci/python:3.7
17-
RUN curl https://saucelabs.com/downloads/sc-4.6.2-linux.tar.gz -o /home/circleci/saucelabs.tar.gz
18-
RUN tar -xzf /home/circleci/saucelabs.tar.gz --directory /home/circleci/
19-
CMD /home/circleci/sc-4.6.2-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_PASSWORD -i $SAUCE_TUNNEL_ID --no-remove-colliding-tunnels -v --se-port 4445
16+
docker run \
17+
-v "$PWD/output/Splunk_TA_UCCExample:/opt/splunk/etc/apps/Splunk_TA_UCCExample" \
18+
-p 8000:8000 \
19+
-p 8088:8088 \
20+
-p 8089:8089 \
21+
-p 9997:9997 \
22+
-e "SPLUNK_START_ARGS=--accept-license" \
23+
-e "SPLUNK_PASSWORD=Chang3d!" \
24+
-e "SPLUNK_HEC_TOKEN=4a8a737d-5452-426c-a6f7-106dca4e813f" \
25+
-e "SPLUNK_DISABLE_POPUPS=true" \
26+
-d \
27+
--rm \
28+
--name splunk splunk/splunk:${1:-latest}

tests/entrypoint.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ui/pytest-ci.ini renamed to tests/ui/pytest.ini

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ markers =
1515
execute_enterprise_cloud_true: Tests to be executed on enterprise cloud
1616
execute_enterprise_cloud_false: Tests not to be executed on enterprise cloud
1717
norecursedirs = .git .venv venv build deps tests/deps node_modules package
18-
addopts = -v -s --tb=long
19-
--splunk-type=external
20-
--splunk-host=splunk
21-
--junitxml=/work/test-results/test.xml
22-
--browser=firefox
23-
--html=/work/test-results/report.html
24-
filterwarnings =
25-
ignore::DeprecationWarning
18+
addopts = -vv
19+
--splunk-type=external
20+
--splunk-host=localhost
21+
--splunk-user=admin
22+
--splunk-password=Chang3d!
23+
--splunk-hec-token=9b741d03-43e9-4164-908b-e09102327d22
24+
--browser=chrome
25+
--local
26+
--persist-browser
27+
--log-level=INFO
28+
--reruns 3

0 commit comments

Comments
 (0)