-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dennis Meister <[email protected]>
- Loading branch information
1 parent
d290e23
commit 9d028c9
Showing
6 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2023 Robert Bosch GmbH | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import json | ||
import os | ||
import platform | ||
from re import Pattern, compile, search | ||
from subprocess import PIPE, Popen, check_output | ||
|
||
|
||
def get_cli_asset_name() -> str: | ||
arch = platform.machine() | ||
if arch == "amd64": | ||
arch = "x64" | ||
if arch == "aarch64": | ||
arch = "arm64" | ||
return f"velocitas-linux-{arch}" | ||
|
||
|
||
def download_older_cli_version(): | ||
cli_asset_name = get_cli_asset_name() | ||
cli_install_path = "/usr/bin/velocitas" | ||
cli_download_url = f"https://github.com/eclipse-velocitas/cli/releases/download/v0.5.4/{cli_asset_name}" # noqa: E501 | ||
|
||
print( | ||
f"Downloading CLI version v0.5.4 from {cli_download_url} to {cli_install_path}" | ||
) | ||
download_cli = f"sudo curl -s -L {cli_download_url} -o {cli_install_path}" | ||
chmod = f"sudo chmod +x {cli_install_path}" | ||
|
||
cli_download_process = Popen(download_cli, stdout=PIPE, shell=True) | ||
cli_download_process.wait() | ||
Popen(chmod, stdout=PIPE, shell=True) | ||
|
||
|
||
def test_post_start_auto_upgrade_cli(): | ||
download_older_cli_version() | ||
|
||
post_create_script_path = os.path.join( | ||
os.getcwd(), "..", "..", "..", "setup", "src", "common", "scripts", "postStartCommand.sh" | ||
) | ||
print(post_create_script_path) | ||
print(post_create_script_path) | ||
post_create_script_process = Popen( | ||
f"{post_create_script_path}", stdout=PIPE, shell=True | ||
) | ||
post_create_script_process.wait() | ||
|
||
velocitas_version_output = check_output(["velocitas", "--version"]).decode() | ||
search_velocitas_version_regex: Pattern[str] = compile( | ||
r"velocitas-cli\/(\w+.\w+.\w+).*" | ||
) | ||
updated_cli_version = search( | ||
search_velocitas_version_regex, velocitas_version_output | ||
).group(1) | ||
|
||
velocitas_json = open(os.path.join(os.getcwd(), ".velocitas.json")) | ||
data = json.load(velocitas_json) | ||
print(data) | ||
assert data["cliVersion"] == f"v{updated_cli_version}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pytest==7.2.1 | ||
pytest-ordering==0.6 | ||
pytest-asyncio==0.20.3 | ||
pytest-cov==4.0.0 | ||
types-mock | ||
coverage2clover==3.3.0 | ||
coveragepy-lcov==0.1.2 |