Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Commit

Permalink
Merge c7a9555 into 4f054c6
Browse files Browse the repository at this point in the history
  • Loading branch information
warcholprzemo committed Apr 23, 2018
2 parents 4f054c6 + c7a9555 commit 86984d0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 40 deletions.
47 changes: 23 additions & 24 deletions master/buildbot/steps/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
from twisted.python import log
import ntpath

# Change artifact location in August
# datetime.datetime(2017, 7, 31, 23, 59, 59, tzinfo=UTC)
ARTIFACT_LOCATION_CHANGE_DATE = epoch2datetime(1501545599)

def FormatDatetime(value):
return value.strftime("%d_%m_%Y_%H_%M_%S_%z")

Expand Down Expand Up @@ -182,7 +178,8 @@ class CheckArtifactExists(ShellCommandResumeBuild, FindPreviousSuccessBuildMixin
descriptionDone="Searching complete."

def __init__(self, artifact=None, artifactDirectory=None, artifactServer=None, artifactServerDir=None,
artifactServerURL=None, artifactServerPort=None, stopBuild=True, resumeBuild=None, **kwargs):
artifactServerURL=None, artifactServerPort=None, stopBuild=True, resumeBuild=None,
customArtifactPath=None, **kwargs):
self.master = None
self.build_sourcestamps = []
if not isinstance(artifact, list):
Expand All @@ -197,6 +194,7 @@ def __init__(self, artifact=None, artifactDirectory=None, artifactServer=None, a
self.artifactPath = None
self.artifactURL = None
self.stopBuild = stopBuild
self.customArtifactPath = customArtifactPath
resume_build_val = stopBuild if resumeBuild is None else resumeBuild
ShellCommandResumeBuild.__init__(self, resumeBuild=resume_build_val, **kwargs)

Expand Down Expand Up @@ -274,12 +272,10 @@ def _previousBuildFound(self, prevBuildRequest):
self.artifactBuildrequest = prevBuildRequest
self.step_status.setText(["Artifact has been already generated."])

if self.artifactBuildrequest["submitted_at"] > ARTIFACT_LOCATION_CHANGE_DATE:
self.artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir,
self.artifactBuildrequest['brid'],
FormatDatetime(self.artifactBuildrequest['submitted_at']))
if self.customArtifactPath:
self.artifactPath = self.customArtifactPath
else:
self.artifactPath = "%s_%s_%s" % (self.build.builder.config.builddir,
self.artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir,
self.artifactBuildrequest['brid'],
FormatDatetime(self.artifactBuildrequest['submitted_at']))

Expand Down Expand Up @@ -312,20 +308,20 @@ class CreateArtifactDirectory(ShellCommand):
descriptionDone="Remote artifact directory created."

def __init__(self, artifactDirectory=None, artifactServer=None, artifactServerDir=None, artifactServerPort=None,
**kwargs):
customArtifactPath=None, **kwargs):
self.artifactDirectory = artifactDirectory
self.artifactServer = artifactServer
self.artifactServerDir = artifactServerDir
self.artifactServerPort = artifactServerPort
self.customArtifactPath = customArtifactPath
ShellCommand.__init__(self, **kwargs)

def start(self):
br = self.build.requests[0]
if mkdt(br.submittedAt) > ARTIFACT_LOCATION_CHANGE_DATE:
artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir,
br.id, FormatDatetime(mkdt(br.submittedAt)))
if self.customArtifactPath:
artifactPath = self.customArtifactPath
else:
artifactPath = "%s_%s_%s" % (self.build.builder.config.builddir,
artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir,
br.id, FormatDatetime(mkdt(br.submittedAt)))

if (self.artifactDirectory):
Expand Down Expand Up @@ -393,7 +389,8 @@ class UploadArtifact(ShellCommand):
descriptionDone="Artifact(s) uploaded."

def __init__(self, artifact=None, artifactDirectory=None, artifactServer=None, artifactServerDir=None,
artifactServerURL=None, artifactServerPort=None, usePowerShell=True, **kwargs):
artifactServerURL=None, artifactServerPort=None, usePowerShell=True,
customArtifactPath=None, **kwargs):
self.artifact=artifact
self.artifactURL = None
self.artifactDirectory = artifactDirectory
Expand All @@ -402,6 +399,7 @@ def __init__(self, artifact=None, artifactDirectory=None, artifactServer=None, a
self.artifactServerURL = artifactServerURL
self.artifactServerPort = artifactServerPort
self.usePowerShell = usePowerShell
self.customArtifactPath = customArtifactPath
ShellCommand.__init__(self, **kwargs)

@defer.inlineCallbacks
Expand All @@ -413,10 +411,10 @@ def start(self):
master = self.build.builder.botmaster.parent
reuse = yield master.db.buildrequests.updateMergedBuildRequest(self.build.requests)

if mkdt(br.submittedAt) > ARTIFACT_LOCATION_CHANGE_DATE:
artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir, br.id, FormatDatetime(mkdt(br.submittedAt)))
if self.customArtifactPath:
artifactPath = self.customArtifactPath
else:
artifactPath = "%s_%s_%s" % (self.build.builder.config.builddir, br.id, FormatDatetime(mkdt(br.submittedAt)))
artifactPath = "%s/%s_%s" % (self.build.builder.config.builddir, br.id, FormatDatetime(mkdt(br.submittedAt)))

artifactServerPath = self.build.getProperty("artifactServerPath", None)
if artifactServerPath is None:
Expand Down Expand Up @@ -445,7 +443,8 @@ class DownloadArtifact(ShellCommand):
descriptionDone="Artifact(s) downloaded."

def __init__(self, artifactBuilderName=None, artifact=None, artifactDirectory=None, artifactDestination=None,
artifactServer=None, artifactServerDir=None, artifactServerPort=None, usePowerShell=True, **kwargs):
artifactServer=None, artifactServerDir=None, artifactServerPort=None, usePowerShell=True,
customArtifactPath=None, **kwargs):
self.artifactBuilderName = artifactBuilderName
self.artifact = artifact
self.artifactDirectory = artifactDirectory
Expand All @@ -455,6 +454,7 @@ def __init__(self, artifactBuilderName=None, artifact=None, artifactDirectory=No
self.artifactDestination = artifactDestination or artifact
self.master = None
self.usePowerShell = usePowerShell
self.customArtifactPath = customArtifactPath
name = "Download Artifact for '%s'" % artifactBuilderName
description = "Downloading artifact '%s'..." % artifactBuilderName
descriptionDone="Downloaded '%s'." % artifactBuilderName
Expand All @@ -469,11 +469,10 @@ def start(self):
#find artifact dependency
br = yield self._getBuildRequest()

if br["submitted_at"] > ARTIFACT_LOCATION_CHANGE_DATE:
artifactPath = "%s/%s_%s" % (safeTranslate(self.artifactBuilderName),
br['brid'], FormatDatetime(br["submitted_at"]))
if self.customArtifactPath:
artifactPath = self.customArtifactPath
else:
artifactPath = "%s_%s_%s" % (safeTranslate(self.artifactBuilderName),
artifactPath = "%s/%s_%s" % (safeTranslate(self.artifactBuilderName),
br['brid'], FormatDatetime(br["submitted_at"]))

if (self.artifactDirectory):
Expand Down
12 changes: 6 additions & 6 deletions master/buildbot/test/unit/test_step_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def tearDown(self):
def setupStep(self, step, brqs=None, winslave=False):
steps.BuildStepMixin.setupStep(self, step)

self.remote = '\'usr@srv.com:/home/srv/web/dir/build_1_17_12_2014_13_31_26_+0000/mydir/myartifact.py\''
self.remote_2 = '\'usr@srv.com:/home/srv/web/dir/B_2_01_01_1970_00_00_00_+0000/mydir/myartifact.py\''
self.remote = '\'usr@srv.com:/home/srv/web/dir/build/1_17_12_2014_13_31_26_+0000/mydir/myartifact.py\''
self.remote_2 = '\'usr@srv.com:/home/srv/web/dir/B/2_01_01_1970_00_00_00_+0000/mydir/myartifact.py\''
self.local = '\'myartifact.py\''

fake_br = fakedb.BuildRequest(id=1, buildsetid=1, buildername="A", complete=1, results=0)
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_create_artifact_directory(self):
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command=['ssh', 'usr@srv.com', 'cd /home/srv/web/dir;', 'mkdir -p ',
'build_1_17_12_2014_13_31_26_+0000/mydir'])
'build/1_17_12_2014_13_31_26_+0000/mydir'])
+ ExpectShell.log('stdio', stdout='')
+ 0
)
Expand All @@ -63,7 +63,7 @@ def test_create_artifact_directory_with_port(self):
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command=['ssh', 'usr@srv.com', '-p 222', 'cd /home/srv/web/dir;', 'mkdir -p ',
'build_1_17_12_2014_13_31_26_+0000/mydir'])
'build/1_17_12_2014_13_31_26_+0000/mydir'])
+ ExpectShell.log('stdio', stdout='')
+ 0
)
Expand All @@ -84,7 +84,7 @@ def test_upload_artifact(self):
)
self.expectOutcome(result=SUCCESS, status_text=['Artifact(s) uploaded.'])
self.expectProperty('artifactServerPath',
'http://srv.com/dir/build_1_17_12_2014_13_31_26_+0000',
'http://srv.com/dir/build/1_17_12_2014_13_31_26_+0000',
'UploadArtifact')
return self.runStep()

Expand All @@ -103,7 +103,7 @@ def test_upload_artifact_with_port(self):
)
self.expectOutcome(result=SUCCESS, status_text=['Artifact(s) uploaded.'])
self.expectProperty('artifactServerPath',
'http://srv.com/dir/build_1_17_12_2014_13_31_26_+0000',
'http://srv.com/dir/build/1_17_12_2014_13_31_26_+0000',
'UploadArtifact')
return self.runStep()

Expand Down
20 changes: 10 additions & 10 deletions master/buildbot/test/unit/test_steps_find_previous_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ def test_checkartifact_build_found_artifact_not_in_srv(self):
command= ['ssh',
'usr@srv.com',
'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',
"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='Not found!!')
Expand All @@ -290,8 +290,8 @@ def test_checkartifact_build_found_artifact_not_in_dir(self):
command= ['ssh',
'usr@srv.com',
'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',
"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='')
Expand All @@ -314,8 +314,8 @@ def test_checkartifact_build_found_artifact_found(self):
command= ['ssh',
'usr@srv.com',
'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',
"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')
Expand All @@ -341,8 +341,8 @@ def canMerge(builder, req1, req2):
command= ['ssh',
'usr@srv.com',
'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',
"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')
Expand Down Expand Up @@ -381,8 +381,8 @@ def isMergingWithPrevious(builder, req1, req2):
command= ['ssh',
'usr@srv.com',
'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',
"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')
Expand Down

0 comments on commit 86984d0

Please sign in to comment.