Beispiel #1
0
def upload_shell(config, dry_run, verbose):
    paths = Paths(config)
    shell_path = paths.target_mojo_shell_path
    target = "%s-%s" % (config.target_os, config.target_arch)
    dest_prefix = "gs://mojo/shell/" + Version().version + "/" + target

    if config.target_os == Config.OS_ANDROID:
        # The APK is already compressed, so zipping it is redundant. We could zip it
        # using zipfile.ZIP_STORED, but not all unzip utilities can correctly unzip
        # a file zipped that way.
        shell_binary_name = os.path.basename(shell_path)
        dest = dest_prefix + "/" + shell_binary_name
        upload(config, shell_path, dest, dry_run)
        return

    # Zip the shell binary and upload it.
    with tempfile.NamedTemporaryFile() as zip_file:
        with zipfile.ZipFile(zip_file, 'w') as z:
            dest = dest_prefix + ".zip"
            with open(shell_path) as shell_binary:
                shell_filename = os.path.basename(shell_path)
                zipinfo = zipfile.ZipInfo(shell_filename)
                zipinfo.external_attr = 0777 << 16L
                zipinfo.compress_type = zipfile.ZIP_DEFLATED
                zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path))
                if verbose:
                    print "zipping %s" % shell_path
                z.writestr(zipinfo, shell_binary.read())
                upload(config, zip_file.name, dest, dry_run)
Beispiel #2
0
def update_version(config, subdir, dry_run):
    with tempfile.NamedTemporaryFile() as temp_version_file:
        version = Version().version
        temp_version_file.write(version)
        temp_version_file.flush()
        dest = "gs://mojo/%s/%s/LATEST" % (subdir, target(config))
        upload(config, temp_version_file.name, dest, dry_run)
Beispiel #3
0
def upload_file(file_path, config, dry_run):
    file_binary_name = os.path.basename(file_path)
    version = Version().version
    gsutil_file_location = "gs://mojo/file/%s/%s" % (version, file_binary_name)

    # Upload the new binary.
    upload(config, file_path, gsutil_file_location, dry_run)
Beispiel #4
0
def upload_shell(config, dry_run, verbose):
    paths = Paths(config)
    zipfile_name = target(config)
    version = Version().version

    # Upload the binary.
    # TODO(blundell): Change this to be in the same structure as the LATEST files,
    # e.g., gs://mojo/shell/linux-x64/<version>/shell.zip.
    dest = "gs://mojo/shell/" + version + "/" + zipfile_name + ".zip"
    with tempfile.NamedTemporaryFile() as zip_file:
        with zipfile.ZipFile(zip_file, 'w') as z:
            shell_path = paths.target_mojo_shell_path
            with open(shell_path) as shell_binary:
                shell_filename = os.path.basename(shell_path)
                zipinfo = zipfile.ZipInfo(shell_filename)
                zipinfo.external_attr = 0777 << 16L
                compress_type = zipfile.ZIP_DEFLATED
                if config.target_os == Config.OS_ANDROID:
                    # The APK is already compressed.
                    compress_type = zipfile.ZIP_STORED
                zipinfo.compress_type = compress_type
                zipinfo.date_time = time.gmtime(os.path.getmtime(shell_path))
                if verbose:
                    print "zipping %s" % shell_path
                z.writestr(zipinfo, shell_binary.read())
        upload(config, zip_file.name, dest, dry_run, gzip=False)

    # Update the LATEST file to contain the version of the new binary.
    latest_file = "gs://mojo/shell/%s/LATEST" % target(config)
    write_file_to_gs(version, latest_file, config, dry_run)
Beispiel #5
0
def upload_system_thunks_lib(config, dry_run):
  paths = Paths(config)
  version = Version().version
  dest = config.values['upload_location'] + \
         ("system_thunks/%s/%s/libsystem_thunks.a" % (target(config), version))
  source_path = paths.build_dir + "/obj/mojo/libsystem_thunks.a"
  upload(config, source_path, dest, dry_run)
Beispiel #6
0
def upload_dart_snapshotter(config, dry_run, verbose):
  # Only built for Linux and Mac.
  if not config.target_os in [Config.OS_LINUX, Config.OS_MAC]:
    return

  paths = Paths(config)
  zipfile_name = target(config)
  version = Version().version

  dest = config.values['upload_location'] + "dart_snapshotter/" + version + \
         "/" + zipfile_name + ".zip"
  with tempfile.NamedTemporaryFile() as zip_file:
    with zipfile.ZipFile(zip_file, 'w') as z:
      dart_snapshotter_path = paths.target_dart_snapshotter_path
      with open(dart_snapshotter_path) as dart_snapshotter_binary:
        dart_snapshotter_filename = os.path.basename(dart_snapshotter_path)
        zipinfo = zipfile.ZipInfo(dart_snapshotter_filename)
        zipinfo.external_attr = 0777 << 16L
        compress_type = zipfile.ZIP_DEFLATED
        zipinfo.compress_type = compress_type
        zipinfo.date_time = time.gmtime(os.path.getmtime(dart_snapshotter_path))
        if verbose:
          print "zipping %s" % dart_snapshotter_path
        z.writestr(zipinfo, dart_snapshotter_binary.read())
    upload(config, zip_file.name, dest, dry_run, gzip=False)

  # Update the LATEST file to contain the version of the new binary.
  latest_file = config.values['upload_location'] + \
                ("dart_snapshotter/%s/LATEST" % target(config))
  write_file_to_gs(version, latest_file, config, dry_run)
Beispiel #7
0
def upload_app(app_binary_path, config, dry_run):
    app_binary_name = os.path.basename(app_binary_path)
    version = Version().version
    gsutil_app_location = ("gs://mojo/services/%s/%s/%s" %
                           (target(config), version, app_binary_name))

    # Upload the new binary.
    upload(config, app_binary_path, gsutil_app_location, dry_run)
Beispiel #8
0
def upload(dry_run, verbose):
    dest = "gs://mojo/shell/" + Version().version + "/linux-x64.zip"

    with tempfile.NamedTemporaryFile() as zip_file:
        with zipfile.ZipFile(zip_file, 'w') as z:
            with open(paths.mojo_shell_path) as shell_binary:
                zipinfo = zipfile.ZipInfo("mojo_shell")
                zipinfo.external_attr = 0777 << 16L
                zipinfo.compress_type = zipfile.ZIP_DEFLATED
                zipinfo.date_time = time.gmtime(
                    os.path.getmtime(paths.mojo_shell_path))
                if verbose:
                    print "zipping %s" % paths.mojo_shell_path
                z.writestr(zipinfo, shell_binary.read())
        if dry_run:
            print str([gsutil_exe, "cp", zip_file.name, dest])
        else:
            subprocess.check_call([gsutil_exe, "cp", zip_file.name, dest])
Beispiel #9
0
def upload_app(app_binary_path, config, dry_run):
    app_binary_name = os.path.basename(app_binary_path)
    version = Version().version
    dest = ("gs://mojo/services/" + target(config) + "/" + version + "/" +
            app_binary_name)
    upload(config, app_binary_path, dest, dry_run)
Beispiel #10
0
def upload_app(app_binary_path, config, dry_run):
    app_binary_name = os.path.basename(app_binary_path)
    target = config.target_os + "-" + config.target_arch
    version = Version().version
    dest = "gs://mojo/services/" + target + "/" + version + "/" + app_binary_name
    upload(config, app_binary_path, dest, dry_run)
def main():
    parser = argparse.ArgumentParser(
        description=
        "A tool that runs a perf test and uploads the resulting data "
        "to the performance dashboard.")

    parser.add_argument(
        "--master-name",
        help="Buildbot master name, used to construct link to buildbot log by "
        "the dashboard, and also as the top-level category for the data.")
    parser.add_argument(
        "--perf-id",
        help="Used as the second-level category for the data, usually the "
        "platform type.")
    parser.add_argument(
        "--test-name",
        help="Name of the test that the perf data was generated from.")
    parser.add_argument(
        "--builder-name",
        help="Buildbot builder name, used to construct link to buildbot log by "
        "the dashboard.")
    parser.add_argument(
        "--build-number",
        type=int,
        help="Build number, used to construct link to buildbot log by the "
        "dashboard.")
    parser.add_argument(
        "--perf-data-path",
        help="The path to the perf data that the perf test generates.")
    server_group = parser.add_mutually_exclusive_group()
    server_group.add_argument(
        "--testing-dashboard",
        action="store_true",
        default=True,
        help="Upload the data to the testing dashboard (default).")
    server_group.add_argument(
        "--production-dashboard",
        dest="testing_dashboard",
        action="store_false",
        default=False,
        help="Upload the data to the production dashboard.")
    parser.add_argument("command", nargs=argparse.REMAINDER)
    args = parser.parse_args()

    subprocess.check_call(args.command)

    if args.master_name is None or \
       args.perf_id is None or \
       args.test_name is None or \
       args.builder_name is None or \
       args.build_number is None or \
       args.perf_data_path is None:
        print "Won't upload perf data to the dashboard because not all of the " \
              "following values are specified: master-name, perf-id, test-name, " \
              "builder-name, build-number, perf-data-path."
        return 0

    revision = Version().version
    perf_data = open(args.perf_data_path, "r")
    point_id = _GetCurrentCommitCount()

    result = perf_data_uploader.UploadPerfData(args.master_name, args.perf_id,
                                               args.test_name,
                                               args.builder_name,
                                               args.build_number, revision,
                                               perf_data, point_id, False,
                                               args.testing_dashboard)

    return 0 if result else 1