Example #1
0
    def test_SubmitAndApprove(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        hash = localClone1.hash()
        localClone1.writeFile("build/product1", "product1 contents")

        solventwrapper.run(localClone1,
                           "submitbuild",
                           env=dict(SOLVENT_CLEAN="yes"))
        solventwrapper.run(localClone1,
                           "approve",
                           env=dict(SOLVENT_CLEAN="yes"))

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__project1__build__%s__clean' % hash
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
        self.assertEquals(self.osmosisPair.official.client().listLabels(),
                          [label])

        self.cleanLocalClonesDir()
        self.assertFalse(localClone1.fileExists("build/product1"))
        self.osmosisPair.local.client().checkout(
            path=gitwrapper.localClonesDir(), label=label)
        self.assertEquals(localClone1.hash(), hash)
        self.assertTrue(localClone1.fileExists("build/product1"))
Example #2
0
    def test_localize(self):
        self.createBuildProduct()

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)

        self.osmosisPair.local.client().eraseLabel(label)
        self.assertEquals(self.osmosisPair.local.client().listLabels(), [])
        solventwrapper.run(os.getcwd(), "localize --label=%s" % label)
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])

        solventwrapper.run(os.getcwd(), "localize --label=%s" % label)

        self.osmosisPair.local.client().eraseLabel(label)
        solventwrapper.runShouldFail(
            os.getcwd(),
            "localize --label=%s" % label,
            "official",
            env=dict(SOLVENT_CONFIG="WITH_OFFICIAL_OBJECT_STORE: No"))
Example #3
0
    def test_LabelExists(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        hash = localClone1.hash()
        localClone1.writeFile("build/product1", "product1 contents")

        solventwrapper.run(localClone1, "submitbuild")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__project1__build__%s__dirty' % hash
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
        self.assertEquals(self.osmosisPair.official.client().listLabels(),
                          [label])

        solventwrapper.run(localClone1, 'labelexists --label=%s' % label)
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=%sA' % label,
                                     "exist")
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=A%s' % label,
                                     "exist")
        solventwrapper.runShouldFail(localClone1, 'labelexists --label=A',
                                     "exist")
        solventwrapper.runShouldFail(localClone1,
                                     'labelexists --label=%s' % label[:-1],
                                     "exist")
Example #4
0
    def test_workDirty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        localProducer.writeFile("imaketheprojectdirty", "dirty dirty boy")
        localProducer.writeFile("../isullytheworkspace", "and my pants too")
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct theProductName build",
                                     "sullied",
                                     env=dict(SOLVENT_CLEAN="yes"))
        solventwrapper.run(localProducer, "submitproduct theProductName build")

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)

        solventwrapper.runWhatever(
            localProducer.directory(),
            "python -m coverage run --parallel-mode -m solvent.cheating --configurationFile=%s "
            "changestate --fromState=dirty --toState=official --product=theProductName"
            % solventwrapper.configurationFile)

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Example #5
0
    def test_unsubmit_empty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        solventwrapper.run(localProducer, "unsubmit")

        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          0)
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 0)
Example #6
0
    def test_ApproveTwiceDoesNotWork_ForceDoesNothing(self):
        localClone1 = gitwrapper.LocalClone(self.project1)

        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")
        solventwrapper.run(localClone1, "approve")
        solventwrapper.runShouldFail(localClone1, "approve", "already")
        solventwrapper.runShouldFail(localClone1,
                                     "approve",
                                     "already",
                                     env=dict(SOLVENT_CONFIG="FORCE: yes"))
Example #7
0
 def test_PrintDependantLabel(self):
     self.createBuildProduct()
     self.cleanLocalClonesDir()
     localClone1 = gitwrapper.LocalClone(self.project1)
     solventwrapper.run(
         localClone1, "addrequirement --originURL=%s --hash=%s" %
         (self.producer.url(), self.producer.hash()))
     expectedLabel = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
     )
     label = solventwrapper.run(
         localClone1,
         "printlabel --repositoryBasename=producer --product=theProductName"
     ).strip()
     self.assertEquals(label, expectedLabel)
Example #8
0
    def test_updateRequirement(self):
        self.createBuildProduct()
        self.cleanLocalClonesDir()
        localClone1 = gitwrapper.LocalClone(self.project1)
        self.assertNotEquals(self.producer.hash()[-2:], "00")
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()[:-2] + "00"))
        previous = localClone1.readFile("solvent.manifest")
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()))
        self.assertEquals(len(localClone1.readFile("solvent.manifest")),
                          len(previous))

        solventwrapper.run(
            localClone1,
            "bring --repository=producer --product=theProductName --destination=%s"
            %
            (os.path.join(localClone1.directory(), "build", "theProductDir")))

        solventwrapper.run(localClone1,
                           "removerequirement --originURLBasename=producer")
        solventwrapper.runShouldFail(
            localClone1,
            "bring --repository=producer --product=theProductName --destination=%s"
            %
            (os.path.join(localClone1.directory(), "build", "theProductDir")),
            "requirement")
Example #9
0
 def test_checkSolventRequirements_DependsOnSolvent__build__productName(
         self):
     self.createBuildProduct()
     self.cleanLocalClonesDir()
     localClone1 = gitwrapper.LocalClone(self.project1)
     solventwrapper.run(
         localClone1, "addrequirement --originURL=%s --hash=%s" %
         (self.producer.url(), self.producer.hash()))
     label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
     )
     buildLabel = 'solvent__producer__build__%s__official' % self.producer.hash(
     )
     solventwrapper.runShouldFail(localClone1, "checkrequirements", "label")
     self.osmosisPair.local.client().renameLabel(label, buildLabel)
     solventwrapper.run(localClone1, "checkrequirements")
Example #10
0
 def createBuildProduct(self):
     self.producer = gitwrapper.GitHub("producer")
     localProducer = gitwrapper.LocalClone(self.producer)
     localProducer.writeFile("build/theDirectory/theProduct",
                             "the contents")
     solventwrapper.configureAsOfficial()
     solventwrapper.run(localProducer, "submitproduct theProductName build")
     self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
     label = 'solvent__producer__theProductName__%s__officialcandidate' % self.producer.hash(
     )
     self.assertEquals(self.osmosisPair.local.client().listLabels(),
                       [label])
     self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                       1)
     solventwrapper.run(localProducer, "approve --product=theProductName")
     return localProducer
Example #11
0
 def test_createBuildProduct_bringLabel(self):
     self.createBuildProduct()
     self.cleanLocalClonesDir()
     label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
     )
     solventwrapper.run(
         gitwrapper.localClonesDir(),
         "bringlabel --label=%s --destination=%s" %
         (label, gitwrapper.localClonesDir()))
     self.assertTrue(
         os.path.isdir(
             os.path.join(gitwrapper.localClonesDir(), "theDirectory")))
     self.assertTrue(
         os.path.exists(
             os.path.join(gitwrapper.localClonesDir(), "theDirectory",
                          "theProduct")))
Example #12
0
    def createAllStates(self):
        localProducer = self.createBuildProduct()
        solventwrapper.configureAsNonOfficial()
        solventwrapper.run(localProducer,
                           "submitproduct theProductName build",
                           env=dict(SOLVENT_CLEAN="yes"))
        solventwrapper.run(localProducer,
                           "approve --product=theProductName",
                           env=dict(SOLVENT_CLEAN="yes"))
        solventwrapper.run(localProducer, "submitproduct theProductName build")

        self.cleanLocalClonesDir()
        localClone1 = gitwrapper.LocalClone(self.project1)
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()))
        officialLabel = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        cleanLabel = 'solvent__producer__theProductName__%s__clean' % self.producer.hash(
        )
        dirtyLabel = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )

        def getCleanLabel():
            return solventwrapper.run(
                localClone1,
                "printlabel --repositoryBasename=producer --product=theProductName",
                env=dict(SOLVENT_CLEAN="Yes")).strip()

        def getDirtyLabel():
            return solventwrapper.run(
                localClone1,
                "printlabel --repositoryBasename=producer --product=theProductName"
            ).strip()

        def noCleanLabel():
            return solventwrapper.runShouldFail(
                localClone1,
                "printlabel --repositoryBasename=producer --product=theProductName",
                "requirement",
                env=dict(SOLVENT_CLEAN="yes"))

        def noDirtyLabel():
            return solventwrapper.runShouldFail(
                localClone1,
                "printlabel --repositoryBasename=producer --product=theProductName",
                "requirement")

        return dict(getCleanLabel=getCleanLabel,
                    getDirtyLabel=getDirtyLabel,
                    noCleanLabel=noCleanLabel,
                    noDirtyLabel=noDirtyLabel,
                    localClone1=localClone1,
                    officialLabel=officialLabel,
                    cleanLabel=cleanLabel,
                    dirtyLabel=dirtyLabel)
Example #13
0
    def test_FulfillUpsetoRequirements_MoreThanOneProject(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")
        solventwrapper.run(localClone1, "approve")

        self.cleanLocalClonesDir()
        localClone2 = gitwrapper.LocalClone(self.project2)
        localClone2.writeFile("build/product2", "product2 contents")
        solventwrapper.run(localClone2, "submitbuild")
        solventwrapper.run(localClone2, "approve")
        solventwrapper.configureAsNonOfficial()

        self.cleanLocalClonesDir()
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        solventwrapper.run(localRequiringProject, "fulfillrequirements")

        self.assertTrue(localClone1.fileExists("build/product1"))
        self.assertTrue(localClone2.fileExists("build/product2"))
Example #14
0
    def test_solventCanBeConfiguredFromTheEnvironment(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        localProducer.writeFile("imaketheprojectdirty", "dirty dirty boy")
        localProducer.writeFile("../isullytheworkspace", "and my pants too")
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct theProductName build",
                                     "sullied",
                                     env=dict(SOLVENT_CONFIG="CLEAN: yes"))
        solventwrapper.run(localProducer, "submitproduct theProductName build")

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Example #15
0
    def test_createBuildProduct_bringExactVersionFromManifestFile(self):
        self.createBuildProduct()
        self.cleanLocalClonesDir()
        localClone1 = gitwrapper.LocalClone(self.project1)
        solventwrapper.run(
            localClone1, "addrequirement --originURL=%s --hash=%s" %
            (self.producer.url(), self.producer.hash()))

        solventwrapper.run(
            localClone1,
            "bring --repository=producer --product=theProductName --destination=%s"
            %
            (os.path.join(localClone1.directory(), "build", "theProductDir")))
        self.assertTrue(
            os.path.isdir(
                os.path.join(localClone1.directory(), "build", "theProductDir",
                             "theDirectory")))
        self.assertTrue(
            os.path.exists(
                os.path.join(localClone1.directory(), "build", "theProductDir",
                             "theDirectory", "theProduct")))
Example #16
0
    def test_SubmitANonUpsetoedProjectOfficialBuild(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        hash = localClone1.hash()
        localClone1.writeFile("build/product1", "product1 contents")

        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__project1__build__%s__officialcandidate' % hash
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
        self.assertEquals(self.osmosisPair.official.client().listLabels(),
                          [label])

        self.cleanLocalClonesDir()
        self.osmosisPair.local.client().checkout(
            path=gitwrapper.localClonesDir(), label=label)
        self.assertEquals(localClone1.hash(), hash)
        self.assertTrue(localClone1.fileExists("build/product1"))
Example #17
0
    def test_createBuildProduct(self):
        self.createBuildProduct()

        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__theProductName__%s__official' % self.producer.hash(
        )
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)

        self.cleanLocalClonesDir()
        solventwrapper.run(
            gitwrapper.localClonesDir(),
            "bring --repository=producer --product=theProductName --hash=%s --destination=%s"
            % (self.producer.hash(), gitwrapper.localClonesDir()))
        self.assertTrue(
            os.path.isdir(
                os.path.join(gitwrapper.localClonesDir(), "theDirectory")))
        self.assertTrue(
            os.path.exists(
                os.path.join(gitwrapper.localClonesDir(), "theDirectory",
                             "theProduct")))
Example #18
0
    def test_ProtectAgainstCommonMistakes_ProcMounted(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/rootfs/etc/config", "the contents")
        os.mkdir(os.path.join(localProducer.directory(), "proc"))
        with open("build/mount.txt", "a") as f:
            f.write(
                "proc on %s/proc type proc (rw,nosuid,nodev,noexec,relatime)\n"
                % (os.path.join(localProducer.directory(), 'build', 'rootfs',
                                'proc'), ))
        solventwrapper.runShouldFail(localProducer,
                                     "submitproduct rootfs build/rootfs",
                                     "mounted")

        solventwrapper.run(
            localProducer,
            "submitproduct rootfs build/rootfs --noCommonMistakesProtection")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 1)
        label = 'solvent__producer__rootfs__%s__dirty' % self.producer.hash()
        self.assertEquals(self.osmosisPair.local.client().listLabels(),
                          [label])
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          1)
Example #19
0
    def test_SubmitTwiceDoesNotWork_ForceWorks(self):
        localClone1 = gitwrapper.LocalClone(self.project1)

        solventwrapper.run(localClone1, "submitbuild")
        solventwrapper.runShouldFail(localClone1, "submitbuild", "already")
        solventwrapper.run(localClone1, "submitbuild --force")
        solventwrapper.runShouldFail(localClone1, "submitbuild", "already")
        solventwrapper.run(localClone1,
                           "submitbuild",
                           env=dict(SOLVENT_CONFIG="FORCE: yes"))
Example #20
0
    def test_FulfillUpsetoRequirements_NoOfficialBuild(self):
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.configureAsOfficial()
        solventwrapper.run(localClone1, "submitbuild")

        self.cleanLocalClonesDir()
        localClone2 = gitwrapper.LocalClone(self.project2)
        localClone2.writeFile("build/product2", "product2 contents")
        solventwrapper.run(localClone2, "submitbuild")
        solventwrapper.run(localClone2, "approve")
        solventwrapper.configureAsNonOfficial()

        self.cleanLocalClonesDir()
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        solventwrapper.runShouldFail(localRequiringProject,
                                     "fulfillrequirements", "build")
Example #21
0
    def test_noOfficialObjectStoreConfigured(self):
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.upseto(localRequiringProject, "fulfillRequirements")
        localRequiringProject.writeFile("build/product2", "product2 contents")

        solventwrapper.configureNoOfficial()
        solventwrapper.configureAsOfficial()
        solventwrapper.run(localRequiringProject, "submitbuild")
        solventwrapper.run(localRequiringProject, "approve")

        self.cleanLocalClonesDir()
        localRecursiveProject = gitwrapper.LocalClone(self.recursiveProject)
        solventwrapper.run(localRecursiveProject, "fulfillrequirements")

        self.assertTrue(localClone1.fileExists("build/product1"))
        self.assertTrue(localRequiringProject.fileExists("build/product2"))
Example #22
0
    def test_unsubmit_dirty(self):
        self.producer = gitwrapper.GitHub("producer")
        localProducer = gitwrapper.LocalClone(self.producer)
        localProducer.writeFile("build/theDirectory/theProduct",
                                "the contents")
        solventwrapper.run(localProducer, "submitbuild")
        solventwrapper.run(localProducer, "submitproduct theProductName build")
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 2)
        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          2)
        label = 'solvent__producer__theProductName__%s__dirty' % self.producer.hash(
        )
        self.assertIn(label, self.osmosisPair.local.client().listLabels())
        label = 'solvent__producer__build__%s__dirty' % self.producer.hash()
        self.assertIn(label, self.osmosisPair.local.client().listLabels())

        solventwrapper.run(localProducer, "unsubmit")

        self.assertEquals(len(self.osmosisPair.official.client().listLabels()),
                          0)
        self.assertEquals(len(self.osmosisPair.local.client().listLabels()), 0)
Example #23
0
    def test_fulfillRequirementsLabelDoesNotExistInLocalOsmosis(self):
        localRequiringProject = gitwrapper.LocalClone(self.requiringProject)
        localClone1 = gitwrapper.LocalClone(self.project1)
        localClone1.writeFile("build/product1", "product1 contents")
        solventwrapper.upseto(localRequiringProject, "fulfillRequirements")
        localRequiringProject.writeFile("build/product2", "product2 contents")

        solventwrapper.configureAsOfficial()
        solventwrapper.run(localRequiringProject, "submitbuild")
        solventwrapper.run(localRequiringProject, "approve")
        solventwrapper.configureAsNonOfficial()

        labels = self.osmosisPair.local.client().listLabels()
        self.assertEquals(len(labels), 1)
        self.osmosisPair.local.client().eraseLabel(labels[0])

        self.cleanLocalClonesDir()
        localRecursiveProject = gitwrapper.LocalClone(self.recursiveProject)
        solventwrapper.run(localRecursiveProject, "fulfillrequirements")

        self.assertTrue(localClone1.fileExists("build/product1"))
        self.assertTrue(localRequiringProject.fileExists("build/product2"))
Example #24
0
 def test_NoRequirements_FulfillDoesNothing(self):
     localClone1 = gitwrapper.LocalClone(self.project1)
     solventwrapper.run(localClone1, "fulfillrequirements")
Example #25
0
 def test_FetchObjectStoresConfiguration(self):
     localClone1 = gitwrapper.LocalClone(self.project1)
     output = solventwrapper.run(localClone1, "printobjectstores").strip()
     self.assertEquals(
         output, "localhost:%d+localhost:%d" %
         (self.osmosisPair.local.port(), self.osmosisPair.official.port()))
Example #26
0
 def getCleanLabel():
     return solventwrapper.run(
         localClone1,
         "printlabel --repositoryBasename=producer --product=theProductName",
         env=dict(SOLVENT_CLEAN="Yes")).strip()
Example #27
0
 def getDirtyLabel():
     return solventwrapper.run(
         localClone1,
         "printlabel --repositoryBasename=producer --product=theProductName"
     ).strip()