Esempio n. 1
0
 def test_checkartifact_when_is_mergin_with_previous_is_true_then_artifact_found(self):
     def isMergingWithPrevious(builder, req1, req2):
         return req1.isMergingWithPrevious and req2.isMergingWithPrevious
     self.setupStep(artifact.CheckArtifactExists(artifact="myartifact.py", artifactDirectory="artifact",
                                     artifactServer='*****@*****.**', artifactServerDir='/home/srv/web/dir',
                                     artifactServerURL="http://srv.com/dir"),
                    sourcestampsInBuild = [FakeSourceStamp(codebase='c',
                                                           repository='https://url/project',
                                                           branch='master',
                                                           revision=12, sourcestampsetid=2)],
                    configuredMergeFnResponse=isMergingWithPrevious)
     self.expectCommands(
         ExpectShell(workdir='wkdir', usePTY='slave-config',
                     command= ['ssh',
           '*****@*****.**',
           'cd /home/srv/web/dir;',
           "if [ -d build/1_01_01_1970_00_00_00_+0000/artifact ]; then echo 'Exists'; else echo 'Not found!!'; fi;",
           'cd build/1_01_01_1970_00_00_00_+0000/artifact',
           '; ls myartifact.py',
           '; ls'])
         + ExpectShell.log('stdio', stdout='myartifact.py')
         + 0
     )
     self.expectOutcome(result=SUCCESS, status_text=['Searching complete.'])
     return self.runStep()
    def test_checkartifact_build_found_artifact_not_in_dir(self):
        self.setupStep(artifact.CheckArtifactExists(
            artifact="myartifact.py",
            artifactDirectory="artifact",
            artifactServer='*****@*****.**',
            artifactServerDir='/home/srv/web/dir',
            artifactServerURL="http://srv.com/dir"),
                       sourcestampsInBuild=[
                           FakeSourceStamp(codebase='c',
                                           repository='https://url/project',
                                           branch='master',
                                           revision=12,
                                           sourcestampsetid=2)
                       ])

        self.expectCommands(
            ExpectShell(
                workdir='wkdir',
                usePTY='slave-config',
                command=[
                    'ssh', '*****@*****.**', 'cd /home/srv/web/dir;',
                    "if [ -d build_1_01_01_1970_00_00_00_+0000/artifact ]; then echo 'Exists'; else echo 'Not found!!'; fi;",
                    'cd build_1_01_01_1970_00_00_00_+0000/artifact',
                    '; ls myartifact.py', '; ls'
                ]) + ExpectShell.log('stdio', stdout='') + 0)
        self.expectOutcome(
            result=SUCCESS,
            status_text=['Artifact not found on server http://srv.com/dir.'])
        return self.runStep()
 def test_checkartifact_previous_build_not_found(self):
     self.setupStep(
         artifact.CheckArtifactExists(
             artifact="myartifact.py",
             artifactDirectory="artifact",
             artifactServer='*****@*****.**',
             artifactServerDir='/home/srv/web/dir',
             artifactServerURL="http://srv.com/dir"))
     self.expectOutcome(result=SUCCESS, status_text=["Artifact not found."])
     return self.runStep()
Esempio n. 4
0
    def test_checkartifact_force_rebuild(self):
        self.setupStep(artifact.CheckArtifactExists(artifact="myartifact.py", artifactDirectory="artifact",
                                        artifactServer='*****@*****.**', artifactServerDir='/home/srv/web/dir',
                                        artifactServerURL="http://srv.com/dir"),
                       sourcestampsInBuild = [FakeSourceStamp(codebase='c',
                                                              repository='https://url/project',
                                                              branch='master',
                                                              revision=12, sourcestampsetid=2)], force_rebuild=True)

        self.expectOutcome(result=SKIPPED, status_text=['Skipping artifact check (forcing a rebuild).'])
        return self.runStep()
Esempio n. 5
0
    def test_checkartifact_when_merge_function_is_false_then_unable_to_merge(self):
        self.setupStep(artifact.CheckArtifactExists(artifact="myartifact.py", artifactDirectory="artifact",
                                        artifactServer='*****@*****.**', artifactServerDir='/home/srv/web/dir',
                                        artifactServerURL="http://srv.com/dir"),
                       sourcestampsInBuild = [FakeSourceStamp(codebase='c',
                                                              repository='https://url/project',
                                                              branch='master',
                                                              revision=12, sourcestampsetid=2)],
                        configuredMergeFnResponse=False)

        self.expectOutcome(result=SKIPPED, status_text=['Skipping artifact check (configured to unmergeable).'])
        return self.runStep()
Esempio n. 6
0
 def test_checkartifact_when_build_found_artifact_exists_and_merge_function_returns_false_then_artifact_not_found(self):
     def cannotMerge(builder, req1, req2):
         return False
     self.setupStep(artifact.CheckArtifactExists(artifact="myartifact.py", artifactDirectory="artifact",
                                     artifactServer='*****@*****.**', artifactServerDir='/home/srv/web/dir',
                                     artifactServerURL="http://srv.com/dir"),
                    sourcestampsInBuild = [FakeSourceStamp(codebase='c',
                                                           repository='https://url/project',
                                                           branch='master',
                                                           revision=12, sourcestampsetid=2)],
                    configuredMergeFnResponse=cannotMerge)
     self.expectOutcome(result=SUCCESS, status_text=['Artifact not found.'])
     return self.runStep()