@Test
  public void testFinalizeUpgrade() throws Exception {
    String hostName = "h1";

    createUpgradeCluster(repositoryVersion2110, hostName);
    createHostVersions(repositoryVersion2111, hostName);

    Cluster cluster = clusters.getCluster(clusterName);

    createUpgrade(cluster, repositoryVersion2111);

    // Finalize the upgrade
    Map<String, String> commandParams = new HashMap<>();
    ExecutionCommand executionCommand = new ExecutionCommand();
    executionCommand.setCommandParams(commandParams);
    executionCommand.setClusterName(clusterName);

    HostRoleCommand hostRoleCommand = hostRoleCommandFactory.create(null, null, null, null);
    hostRoleCommand.setExecutionCommandWrapper(new ExecutionCommandWrapper(executionCommand));

    finalizeUpgradeAction.setExecutionCommand(executionCommand);
    finalizeUpgradeAction.setHostRoleCommand(hostRoleCommand);

    // this should fail since the host versions have not moved to current
    CommandReport report = finalizeUpgradeAction.execute(null);
    assertEquals(HostRoleStatus.FAILED.name(), report.getStatus());

    List<HostVersionEntity> hostVersions = hostVersionDAO.findHostVersionByClusterAndRepository(
        cluster.getClusterId(), repositoryVersion2111);

    for (HostVersionEntity hostVersion : hostVersions) {
      hostVersion.setState(RepositoryVersionState.CURRENT);
    }

    report = finalizeUpgradeAction.execute(null);
    assertEquals(HostRoleStatus.COMPLETED.name(), report.getStatus());

    hostVersions = hostVersionDAO.findHostVersionByClusterAndRepository(cluster.getClusterId(),
        repositoryVersion2111);

    for (HostVersionEntity hostVersion : hostVersions) {
      Collection<HostComponentStateEntity> hostComponentStates = hostComponentStateDAO.findByHost(hostVersion.getHostName());
      for (HostComponentStateEntity hostComponentStateEntity: hostComponentStates) {
       assertEquals(UpgradeState.NONE, hostComponentStateEntity.getUpgradeState());
      }
    }
  }
During an Express Upgrade that crosses a stack version, Ambari calls UpdateDesiredRepositoryAction
in order to change the stack and apply configs.
The configs that are applied must be saved with the username that is passed in the role params.
ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java