Ejemplo n.º 1
0
def test_update(request, client, version):
    container_name = "%s-monitoring" % branch_name

    # Pick a random old version that we can use to the setup the initial site with
    # Later this site is being updated to the current daily build
    old_version = testlib.CMKVersion(
        version_spec="2.1.0b3",
        branch="2.1.0",
        edition=testlib.CMKVersion.CRE,
    )

    # 1. create container with old version and add a file to mark the pre-update state
    c_orig = _start(request,
                    client,
                    version=old_version,
                    name=container_name,
                    volumes=["/omd/sites"])
    assert (c_orig.exec_run(["touch", "pre-update-marker"],
                            user="******",
                            workdir="/omd/sites/cmk")[0] == 0)

    # 2. stop the container
    c_orig.stop()

    # 3. rename old container
    c_orig.rename("%s-old" % container_name)

    # 4. create new container
    c_new = _start(
        request,
        client,
        version=version,
        is_update=True,
        name=container_name,
        volumes_from=c_orig.id,
    )

    # 5. verify result
    _exec_run(c_new, ["omd", "version"],
              user="******")[1].endswith("%s\n" % version.omd_version())
    assert (_exec_run(c_new, ["test", "-f", "pre-update-marker"],
                      user="******",
                      workdir="/omd/sites/cmk")[0] == 0)
Ejemplo n.º 2
0
def test_update(request, client, version):
    container_name = "%s-monitoring" % branch_name

    # Pick a random old version that we can use to the setup the initial site with
    # Later this site is being updated to the current daily build
    old_version = testlib.CMKVersion(
        version_spec="1.5.0p5",
        branch="1.5.0",
        edition=testlib.CMKVersion.CRE,
    )

    # 1. create container with old version and add a file to mark the pre-update state
    c_orig = _start(
        request, client, version=old_version, name=container_name, volumes=["/omd/sites"]
    )
    assert (
        c_orig.exec_run(["touch", "pre-update-marker"], user="******", workdir="/omd/sites/cmk")[0]
        == 0
    )

    # Until we have a "old version" with .version_meta directory that we can update
    # from produce this directory manually here.
    # TODO: Once we update from a 1.6 version this can be dropped
    assert c_orig.exec_run(["mkdir", ".version_meta"], user="******", workdir="/omd/sites/cmk")[0] == 0
    assert (
        c_orig.exec_run(
            ["cp", "-pr", "version/skel", ".version_meta/"], user="******", workdir="/omd/sites/cmk"
        )[0]
        == 0
    )
    assert (
        c_orig.exec_run(
            ["cp", "-pr", "version/share/omd/skel.permissions", ".version_meta/"],
            user="******",
            workdir="/omd/sites/cmk",
        )[0]
        == 0
    )
    assert (
        c_orig.exec_run(
            ["bash", "-c", "echo '%s' > .version_meta/version" % old_version.omd_version()],
            user="******",
            workdir="/omd/sites/cmk",
        )[0]
        == 0
    )

    # 2. stop the container
    c_orig.stop()

    # 3. rename old container
    c_orig.rename("%s-old" % container_name)

    # 4. create new container
    c_new = _start(
        request,
        client,
        version=version,
        is_update=True,
        name=container_name,
        volumes_from=c_orig.id,
    )

    # 5. verify result
    _exec_run(c_new, ["omd", "version"], user="******")[1].endswith("%s\n" % version.omd_version())
    assert (
        _exec_run(c_new, ["test", "-f", "pre-update-marker"], user="******", workdir="/omd/sites/cmk")[
            0
        ]
        == 0
    )
Ejemplo n.º 3
0
def build_version():
    return testlib.CMKVersion(
        version_spec=os.environ.get("VERSION", testlib.CMKVersion.DAILY),
        edition=os.environ.get("EDITION", testlib.CMKVersion.CEE),
        branch=branch_name,
    )