Example #1
0
def test_package_metadata():
    _install_helloworld()

    # test marathon labels
    expected_source = bytes(
        UNIVERSE_TEST_REPOS['helloworld-universe'],
        'utf-8'
    )

    expected_labels = {
        'DCOS_PACKAGE_NAME': b'helloworld',
        'DCOS_PACKAGE_VERSION': b'0.1.0',
        'DCOS_PACKAGE_SOURCE': expected_source,
    }

    app_labels = _get_app_labels('helloworld')
    for label, value in expected_labels.items():
        assert value == six.b(app_labels.get(label))

    # test local package.json
    package = file_json(
        'tests/data/package/json/test_package_metadata.json')
    package = json.loads(package.decode("UTF-8"))

    cmd = subcommand.InstalledSubcommand("dcos-http")

    # test local package.json
    assert cmd.package_json()['marathon'] == package['marathon']

    # uninstall helloworld
    _uninstall_helloworld()
    # TODO(janisz): Remove after DCOS_OSS-5619
    assert_command(['dcos', 'plugin', 'remove', 'dcos-http'])
Example #2
0
def test_package_metadata():
    _install_helloworld()

    # test marathon labels
    expected_source = bytes(UNIVERSE_TEST_REPOS['helloworld-universe'],
                            'utf-8')

    expected_labels = {
        'DCOS_PACKAGE_NAME': b'helloworld',
        'DCOS_PACKAGE_VERSION': b'0.1.0',
        'DCOS_PACKAGE_SOURCE': expected_source,
    }

    app_labels = _get_app_labels('helloworld')
    for label, value in expected_labels.items():
        assert value == six.b(app_labels.get(label))

    # test local package.json
    package = file_json('tests/data/package/json/test_package_metadata.json')
    package = json.loads(package.decode("UTF-8"))

    helloworld_subcommand = subcommand.InstalledSubcommand("helloworld")

    # test local package.json
    assert helloworld_subcommand.package_json() == package

    # uninstall helloworld
    _uninstall_helloworld()
Example #3
0
def test_package_metadata():
    _install_helloworld()

    # test marathon labels
    expected_metadata = b"""eyJ3ZWJzaXRlIjoiaHR0cHM6Ly9naXRodWIuY29tL21lc29zcG\
hlcmUvZGNvcy1oZWxsb3dvcmxkIiwibmFtZSI6ImhlbGxvd29ybGQiLCJwb3N0SW5zdGFsbE5vdGVz\
IjoiQSBzYW1wbGUgcG9zdC1pbnN0YWxsYXRpb24gbWVzc2FnZSIsImRlc2NyaXB0aW9uIjoiRXhhbX\
BsZSBEQ09TIGFwcGxpY2F0aW9uIHBhY2thZ2UiLCJwYWNrYWdpbmdWZXJzaW9uIjoiMi4wIiwidGFn\
cyI6WyJtZXNvc3BoZXJlIiwiZXhhbXBsZSIsInN1YmNvbW1hbmQiXSwibWFpbnRhaW5lciI6InN1cH\
BvcnRAbWVzb3NwaGVyZS5pbyIsInZlcnNpb24iOiIwLjEuMCIsInByZUluc3RhbGxOb3RlcyI6IkEg\
c2FtcGxlIHByZS1pbnN0YWxsYXRpb24gbWVzc2FnZSJ9"""

    expected_command = b"""eyJwaXAiOlsiZGNvczwxLjAiLCJnaXQraHR0cHM6Ly9naXRodWI\
uY29tL21lc29zcGhlcmUvZGNvcy1oZWxsb3dvcmxkLmdpdCNkY29zLWhlbGxvd29ybGQ9MC4xLjAiX\
X0="""

    expected_source = b"""https://github.com/mesosphere/universe/archive/\
cli-test-4.zip"""

    expected_labels = {
        'DCOS_PACKAGE_REGISTRY_VERSION': b'2.0',
        'DCOS_PACKAGE_NAME': b'helloworld',
        'DCOS_PACKAGE_VERSION': b'0.1.0',
        'DCOS_PACKAGE_SOURCE': expected_source,
        'DCOS_PACKAGE_RELEASE': b'0',
    }

    app_labels = _get_app_labels('helloworld')
    for label, value in expected_labels.items():
        assert value == six.b(app_labels.get(label))

    # these labels are different for cosmos b/c of null problem
    # we have cosmos tests for test, and will fix in issue 431
    assert expected_metadata == six.b(
        app_labels.get('DCOS_PACKAGE_METADATA'))
    assert expected_command == six.b(
        app_labels.get('DCOS_PACKAGE_COMMAND'))

    # test local package.json
    package = {
        "description": "Example DCOS application package",
        "maintainer": "*****@*****.**",
        "name": "helloworld",
        "packagingVersion": "2.0",
        "postInstallNotes": "A sample post-installation message",
        "preInstallNotes": "A sample pre-installation message",
        "tags": ["mesosphere", "example", "subcommand"],
        "version": "0.1.0",
        "website": "https://github.com/mesosphere/dcos-helloworld",
    }

    helloworld_subcommand = subcommand.InstalledSubcommand("helloworld")

    # test local package.json
    assert _remove_nulls(helloworld_subcommand.package_json()) == package

    # uninstall helloworld
    _uninstall_helloworld()
Example #4
0
def installed_subcommands():
    """Returns all installed subcommands.

    :returns: all installed subcommands
    :rtype: [InstalledSubcommand]
    """

    return [subcommand.InstalledSubcommand(name) for name in
            subcommand.distributions()]
Example #5
0
def test_package_metadata():
    _install_helloworld()

    # test marathon labels
    expected_metadata = {
        'maintainer': '*****@*****.**',
        'framework': False,
        'name': 'helloworld',
        'version': '0.1.0',
        'packagingVersion': '3.0',
        'preInstallNotes': 'A sample pre-installation message',
        'selected': False,
        'website': 'https://github.com/mesosphere/dcos-helloworld',
        'description': 'Example DCOS application package',
        'tags': ['mesosphere', 'example', 'subcommand'],
        'postInstallNotes': 'A sample post-installation message'
    }

    expected_source = bytes(UNIVERSE_TEST_REPOS['helloworld-universe'],
                            'utf-8')

    expected_labels = {
        'DCOS_PACKAGE_NAME': b'helloworld',
        'DCOS_PACKAGE_VERSION': b'0.1.0',
        'DCOS_PACKAGE_SOURCE': expected_source,
    }

    app_labels = _get_app_labels('helloworld')
    for label, value in expected_labels.items():
        assert value == six.b(app_labels.get(label))

    assert expected_metadata == base64_to_dict(
        six.b(app_labels.get('DCOS_PACKAGE_METADATA')))

    # test local package.json
    package = {
        "description": "Example DCOS application package",
        "framework": False,
        "maintainer": "*****@*****.**",
        "name": "helloworld",
        "packagingVersion": "3.0",
        "postInstallNotes": "A sample post-installation message",
        "preInstallNotes": "A sample pre-installation message",
        "selected": False,
        "tags": ["mesosphere", "example", "subcommand"],
        "version": "0.1.0",
        "website": "https://github.com/mesosphere/dcos-helloworld",
    }

    helloworld_subcommand = subcommand.InstalledSubcommand("helloworld")

    # test local package.json
    assert helloworld_subcommand.package_json() == package

    # uninstall helloworld
    _uninstall_helloworld()