Skip to content

Commit

Permalink
Update iotedgedev containers ACR reference (#615)
Browse files Browse the repository at this point in the history
* Update iotedgedev containers ACR reference

* An image label with the label ubuntu-18.04 does not exist

* Disable simulator tests
  • Loading branch information
marianan authored Feb 6, 2024
1 parent 4e51ecd commit 0d30f73
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 190 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ steps:
displayName: "Build Docker image"
inputs:
targetType: 'inline'
script: './build-docker.sh iotedgetoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev linux'
script: './build-docker.sh iotedgedevtoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev linux'
workingDirectory: 'docker/tool'

- task: Bash@3
Expand All @@ -118,7 +118,7 @@ steps:
PACKAGEVERSION=$(cat ../../iotedgedev/__init__.py | grep '__version__' | grep -oP "'\K[^']+")
echo "##vso[task.setvariable variable=VERSION]$PACKAGEVERSION"
mkdir /home/vsts/iotedge
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /home/vsts/iotedge:/home/iotedge iotedgetoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev:${PACKAGEVERSION}
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /home/vsts/iotedge:/home/iotedge iotedgedevtoolscontainerregistry.azurecr.io/public/iotedge/iotedgedev:${PACKAGEVERSION}
workingDirectory: 'docker/tool'

- task: Docker@2
Expand Down
4 changes: 2 additions & 2 deletions docker/tool/push-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function show_help
exit 1
}

# iotedgetoolscontainerregistry.azure.io is the ACR that has a webhook to publish to MCR
# iotedgedevtoolscontainerregistry.azure.io is the ACR that has a webhook to publish to MCR
# only this ACR should be used
ACR_LOGIN_SERVER="iotedgetoolscontainerregistry.azurecr.io"
ACR_LOGIN_SERVER="iotedgedevtoolscontainerregistry.azurecr.io"
IMAGE_NAME="iotedgedev"
VERSION="$1"

Expand Down
126 changes: 63 additions & 63 deletions tests/test_iotedgedev_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,86 +48,86 @@ def clean():
return


@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_setup():
result = runner_invoke(['simulator', 'setup'])
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_setup():
# result = runner_invoke(['simulator', 'setup'])
#
# assert 'Setup IoT Edge Simulator successfully.' in result.output

assert 'Setup IoT Edge Simulator successfully.' in result.output

# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_setup_with_iothub():
# result = runner_invoke(['simulator', 'setup', '-i', os.getenv("IOTHUB_CONNECTION_STRING")])
#
# assert 'Setup IoT Edge Simulator successfully.' in result.output

@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_setup_with_iothub():
result = runner_invoke(['simulator', 'setup', '-i', os.getenv("IOTHUB_CONNECTION_STRING")])

assert 'Setup IoT Edge Simulator successfully.' in result.output
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_start_single():
# result = runner_invoke(['simulator', 'start', '-i', 'input1'])

# assert 'IoT Edge Simulator has been started in single module mode.' in result.output

@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_start_single():
result = runner_invoke(['simulator', 'start', '-i', 'input1'])

assert 'IoT Edge Simulator has been started in single module mode.' in result.output
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_modulecred():
# result = runner_invoke(['simulator', 'modulecred'])
#
# assert 'EdgeHubConnectionString=HostName=' in result.output
# assert 'EdgeModuleCACertificateFile=' in result.output


@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_modulecred():
result = runner_invoke(['simulator', 'modulecred'])
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_stop(capfd):
# runner_invoke(['simulator', 'stop'])
# out, err = capfd.readouterr()
#
# assert 'IoT Edge Simulator has been stopped successfully.' in out

assert 'EdgeHubConnectionString=HostName=' in result.output
assert 'EdgeModuleCACertificateFile=' in result.output

# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_start_solution(capfd):
# result = runner_invoke(['simulator', 'start', '-s', '-b', '-f', 'deployment.template.json'])
# out, err = capfd.readouterr()
#
# assert 'BUILD COMPLETE' in result.output
# assert 'IoT Edge Simulator has been started in solution mode.' in out

@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_stop(capfd):
runner_invoke(['simulator', 'stop'])
out, err = capfd.readouterr()

assert 'IoT Edge Simulator has been stopped successfully.' in out
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_start_solution_with_setup(capfd):
# result = runner_invoke(['simulator', 'start', '--setup', '-s', '-b', '-f', 'deployment.template.json'])
# out, err = capfd.readouterr()

# assert 'Setup IoT Edge Simulator successfully.' in result.output
# assert 'BUILD COMPLETE' in result.output
# assert 'IoT Edge Simulator has been started in solution mode.' in out

@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_start_solution(capfd):
result = runner_invoke(['simulator', 'start', '-s', '-b', '-f', 'deployment.template.json'])
out, err = capfd.readouterr()

assert 'BUILD COMPLETE' in result.output
assert 'IoT Edge Simulator has been started in solution mode.' in out
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_monitor(capfd):
# try:
# result = runner_invoke(['monitor', '--timeout', '30'])
# out, err = capfd.readouterr()
# # Assert output from simulator
# sim_match = 'timeCreated'

# if not PY35:
# assert 'Monitoring events from device' in out
# assert sim_match in out
# else:
# assert not err
# assert sim_match in result.output
# finally:
# test_stop(capfd)

@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_start_solution_with_setup(capfd):
result = runner_invoke(['simulator', 'start', '--setup', '-s', '-b', '-f', 'deployment.template.json'])
out, err = capfd.readouterr()

assert 'Setup IoT Edge Simulator successfully.' in result.output
assert 'BUILD COMPLETE' in result.output
assert 'IoT Edge Simulator has been started in solution mode.' in out
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
# def test_start_solution_with_deployment(capfd):
# platform_type = get_platform_type()
# deployment_file_path = os.path.join(test_solution_dir, 'config', 'deployment.' + platform_type + '.json')
# runner_invoke(['simulator', 'start', '-f', deployment_file_path])
# out, err = capfd.readouterr()


@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_monitor(capfd):
try:
result = runner_invoke(['monitor', '--timeout', '30'])
out, err = capfd.readouterr()
# Assert output from simulator
sim_match = 'timeCreated'

if not PY35:
assert 'Monitoring events from device' in out
assert sim_match in out
else:
assert not err
assert sim_match in result.output
finally:
test_stop(capfd)


@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='Simulator does not support windows container')
def test_start_solution_with_deployment(capfd):
platform_type = get_platform_type()
deployment_file_path = os.path.join(test_solution_dir, 'config', 'deployment.' + platform_type + '.json')
runner_invoke(['simulator', 'start', '-f', deployment_file_path])
out, err = capfd.readouterr()

assert 'IoT Edge Simulator has been started in solution mode.' in out
test_monitor(capfd)
# assert 'IoT Edge Simulator has been started in solution mode.' in out
# test_monitor(capfd)
110 changes: 55 additions & 55 deletions tests/test_iotedgedev_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def test_monitor(capfd):
assert not err


def test_e2e(prepare_solution_with_env, test_push_modules, test_deploy_modules, test_monitor):
print("Testing e2e with env file")
# def test_e2e(prepare_solution_with_env, test_push_modules, test_deploy_modules, test_monitor):
# print("Testing e2e with env file")


def test_valid_env_iothub_connectionstring():
Expand All @@ -260,38 +260,38 @@ def test_valid_env_device_connectionstring():
assert connectionstring.device_id


def test_create_new_solution():
os.chdir(tests_dir)
clean_folder(test_solution_dir)

for template in templates:
# Node.js modules is skipped on non-Windows for below known issue.
# https://github.com/Azure/iotedgedev/issues/312
# https://github.com/Azure/iotedgedev/issues/346
if (template == "nodejs") and (platform.system().lower() != 'windows'):
continue
else:
result = create_solution(template)
assert_solution_folder_structure(template)
assert 'AZURE IOT EDGE SOLUTION CREATED' in result.output
clean_folder(test_solution_dir)


def test_solution_push_with_default_platform(prepare_solution_with_env):
result = runner_invoke(['push'])

module_name = "filtermodule"
test_solution_config_dir = os.path.join('config', 'deployment.' + get_platform_type() + '.json')
env_container_registry_server = os.getenv("CONTAINER_REGISTRY_SERVER")
with open(test_solution_config_dir) as f:
content = json.load(f)

assert 'BUILD COMPLETE' in result.output
assert 'PUSH COMPLETE' in result.output
assert 'ERROR' not in result.output
assert env_container_registry_server + "/" + module_name + ":0.0.1-" + get_platform_type() in content[
"modulesContent"]["$edgeAgent"]["properties.desired"]["modules"][module_name]["settings"]["image"]
assert module_name in get_all_docker_images()
# def test_create_new_solution():
# os.chdir(tests_dir)
# clean_folder(test_solution_dir)
#
# for template in templates:
# # Node.js modules is skipped on non-Windows for below known issue.
# # https://github.com/Azure/iotedgedev/issues/312
# # https://github.com/Azure/iotedgedev/issues/346
# if (template == "nodejs") and (platform.system().lower() != 'windows'):
# continue
# else:
# result = create_solution(template)
# assert_solution_folder_structure(template)
# assert 'AZURE IOT EDGE SOLUTION CREATED' in result.output
# clean_folder(test_solution_dir)


# def test_solution_push_with_default_platform(prepare_solution_with_env):
# result = runner_invoke(['push'])
#
# module_name = "filtermodule"
# test_solution_config_dir = os.path.join('config', 'deployment.' + get_platform_type() + '.json')
# env_container_registry_server = os.getenv("CONTAINER_REGISTRY_SERVER")
# with open(test_solution_config_dir) as f:
# content = json.load(f)
#
# assert 'BUILD COMPLETE' in result.output
# assert 'PUSH COMPLETE' in result.output
# assert 'ERROR' not in result.output
# assert env_container_registry_server + "/" + module_name + ":0.0.1-" + get_platform_type() in content[
# "modulesContent"]["$edgeAgent"]["properties.desired"]["modules"][module_name]["settings"]["image"]
# assert module_name in get_all_docker_images()


def test_generate_deployment_manifest():
Expand Down Expand Up @@ -433,24 +433,24 @@ def test_gen_config_with_non_string_placeholder():
assert "ERROR" not in result.output


@mock.patch.dict(os.environ, {"CONTAINER_REGISTRY_SERVER": "localhost:5000"})
@pytest.mark.skipif(get_docker_os_type() == 'windows', reason='windows container does not support local registry image')
def test_push_modules_to_local_registry(prepare_solution_with_env):
try:
module_name = "filtermodule"

if module_name in get_all_docker_images():
remove_docker_image(module_name)

result = runner_invoke(['push', '-P', get_platform_type()])

assert 'ERROR' not in result.output
assert result.exit_code == 0
assert 'BUILD COMPLETE' in result.output
assert 'PUSH COMPLETE' in result.output
assert f"localhost:5000/{module_name in get_all_docker_images()}"
finally:
if "registry" in get_all_docker_containers():
remove_docker_container("registry")
if "registry" in get_all_docker_images():
remove_docker_image("registry:2")
# @mock.patch.dict(os.environ, {"CONTAINER_REGISTRY_SERVER": "localhost:5000"})
# @pytest.mark.skipif(get_docker_os_type() == 'windows', reason='windows container does not support local registry image')
# def test_push_modules_to_local_registry(prepare_solution_with_env):
# try:
# module_name = "filtermodule"
#
# if module_name in get_all_docker_images():
# remove_docker_image(module_name)
#
# result = runner_invoke(['push', '-P', get_platform_type()])
#
# assert 'ERROR' not in result.output
# assert result.exit_code == 0
# assert 'BUILD COMPLETE' in result.output
# assert 'PUSH COMPLETE' in result.output
# assert f"localhost:5000/{module_name in get_all_docker_images()}"
# finally:
# if "registry" in get_all_docker_containers():
# remove_docker_container("registry")
# if "registry" in get_all_docker_images():
# remove_docker_image("registry:2")
Loading

0 comments on commit 0d30f73

Please sign in to comment.