<commit_before>#!/usr/bin/perl -w
#
# This tool creates a new Jenkins config file for the openstack-unittests trigger jobs.
#
#
my $subproject="Master";
my $obsproject="Cloud:OpenStack:$subproject";
my $projectsource="PROJECTSOURCE=OBS/$obsproject";

my $uttrigger = {
    functest   => { 'openstack-swift' =>
'COMPONENT=openstack-swift
SETUPCMD=swift-init main start
TESTCMD=./.functests
TEARDOWNCMD=swift-init main stop'
    },
    probetests => { 'openstack-swift' =>
'COMPONENT=openstack-swift
SETUPCMD=swift-init all start
TESTCMD=./.probetests
TEARDOWNCMD=swift-init all stop'
    },
    unittest   => {
        'openstack-ceilometer'        =>
'COMPONENT=openstack-ceilometer
TESTCMD=./run_tests.sh -N',
        'openstack-cinder'            => 'COMPONENT=openstack-cinder',
        'openstack-cinderclient'      => 'COMPONENT=python-cinderclient',
        'openstack-dashboard'         => 'COMPONENT=openstack-dashboard',
        'openstack-glance'            =>
'COMPONENT=openstack-glance
TESTCMD=./run_tests.sh -N glance',
        'openstack-keystone'          =>
'COMPONENT=openstack-keystone',
        'openstack-nova'              => 'COMPONENT=openstack-nova',
        'openstack-quantum'           => 'COMPONENT=openstack-quantum',
        'openstack-swift'             =>
'COMPONENT=openstack-swift
SWIFT_TEST_CONFIG_FILE=/etc/swift/func_test.conf
TESTCMD=./.unittests',
        'python-glanceclient'         =>
'COMPONENT=python-glanceclient
TESTCMD=nosetests',
        'python-heatclient'           => 'COMPONENT=python-heatclient',
        'python-keystoneclient'       => 'COMPONENT=python-keystoneclient',
        'python-novaclient'           => 'COMPONENT=python-novaclient',
        'python-quantumclient'        =>
'COMPONENT=python-quantumclient
TESTCMD=nosetests',
        'python-swiftclient'          => 'COMPONENT=python-swiftclient'
    }
};
my @output = ();
my @output_create = ();

my $apicheckcgi= "http://clouddata.cloud.suse.de/cgi-bin/apicheck";
my $obsapi = "api.opensuse.org";
my $apicheck="$apicheckcgi/$obsapi/build/$obsproject/SLE_11_SP2/x86_64";

foreach my $testtype (keys %{$uttrigger})
{
  foreach my $package (keys $uttrigger->{$testtype})
  {
      my $jobname = "$testtype-$package-$subproject";
      my $jobenv = $uttrigger->{$testtype}->{$package}."\n$projectsource";
      open (my $FH, '>', "$jobname.config.xml") or die $@;
      select $FH;

print qq{<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description>Starts some services and triggers the cloud-$jobname
&lt;br /&gt;&#xd;
&lt;b&gt;Changes to this job ONLY via the &lt;i&gt;openstack-unittest.config.xml.pl&lt;/i&gt; tool from the automation repo.&lt;/b&gt;
</description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="hudson.scm.NullSCM"/>
  <assignedNode>openstack-unittest</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers class="vector">
    <org.jenkinsci.plugins.urltrigger.URLTrigger>
      <spec>*/10 * * * *</spec>
      <entries>
        <org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
          <url>$apicheck/$package</url>
          <proxyActivated>false</proxyActivated>
          <checkStatus>false</checkStatus>
          <statusCode>200</statusCode>
          <checkLastModificationDate>false</checkLastModificationDate>
          <inspectingContent>true</inspectingContent>
          <contentTypes>
            <org.jenkinsci.plugins.urltrigger.content.SimpleContentType/>
          </contentTypes>
        </org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
      </entries>
      <labelRestriction>false</labelRestriction>
    </org.jenkinsci.plugins.urltrigger.URLTrigger>
  </triggers>
  <concurrentBuild>false</concurrentBuild>
  <builders/>
  <publishers>
    <hudson.plugins.parameterizedtrigger.BuildTrigger>
      <configs>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
              <properties>$jobenv</properties>
            </hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
          </configs>
          <projects>openstack-unittest, </projects>
          <condition>SUCCESS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
      </configs>
    </hudson.plugins.parameterizedtrigger.BuildTrigger>
  </publishers>
  <buildWrappers/>
</project>

};

    select STDOUT;
    close $FH;

    push @output, 'curl -X POST --data-binary @'."$jobname.config.xml http://river.suse.de/job/cloud-$jobname-trigger/config.xml";
    push @output_create, 'curl -H "Content-Type: text/xml" -X POST --data-binary @'."$jobname.config.xml http://river.suse.de/createItem?name=cloud-$jobname-trigger";

  }
}

print "\nConfigs created locally\n";
print "Please update the jenkins config by running these commands:\n";

print "_Update_ the jobs with these commands:\n";
print join("\n", @output)."\n";
print "----------------------\n";
print "_Create_ the jobs with these commands:\n";
print join("\n", @output_create)."\n";<commit_msg>add support to upload the changed unittest trigger jobs<commit_after>#!/usr/bin/perl -w
#
# This tool creates a new Jenkins config file for the openstack-unittests trigger jobs.
# With the first prarameter being set to "upload" all jobs will be updated/created
#

my $upload = ($ARGV[0] =~ /^upload$/) ? 1:0;

my $subproject="Master";
my $obsproject="Cloud:OpenStack:$subproject";
my $projectsource="PROJECTSOURCE=OBS/$obsproject";

my $uttrigger = {
    functest   => { 'openstack-swift' =>
'COMPONENT=openstack-swift
SETUPCMD=swift-init main start
TESTCMD=./.functests
TEARDOWNCMD=swift-init main stop'
    },
    probetests => { 'openstack-swift' =>
'COMPONENT=openstack-swift
SETUPCMD=swift-init all start
TESTCMD=./.probetests
TEARDOWNCMD=swift-init all stop'
    },
    unittest   => {
        'openstack-ceilometer'        =>
'COMPONENT=openstack-ceilometer
TESTCMD=./run_tests.sh -N',
        'openstack-cinder'            => 'COMPONENT=openstack-cinder',
        'openstack-cinderclient'      => 'COMPONENT=python-cinderclient',
        'openstack-dashboard'         => 'COMPONENT=openstack-dashboard',
        'openstack-glance'            =>
'COMPONENT=openstack-glance
TESTCMD=./run_tests.sh -N glance',
        'openstack-keystone'          =>
'COMPONENT=openstack-keystone',
        'openstack-nova'              => 'COMPONENT=openstack-nova',
        'openstack-quantum'           => 'COMPONENT=openstack-quantum',
        'openstack-swift'             =>
'COMPONENT=openstack-swift
SWIFT_TEST_CONFIG_FILE=/etc/swift/func_test.conf
TESTCMD=./.unittests',
        'python-glanceclient'         =>
'COMPONENT=python-glanceclient
TESTCMD=nosetests',
        'python-heatclient'           => 'COMPONENT=python-heatclient',
        'python-keystoneclient'       => 'COMPONENT=python-keystoneclient',
        'python-novaclient'           => 'COMPONENT=python-novaclient',
        'python-quantumclient'        =>
'COMPONENT=python-quantumclient
TESTCMD=nosetests',
        'python-swiftclient'          => 'COMPONENT=python-swiftclient'
    }
};
my @output = ();
my @output_create = ();

my $apicheckcgi= "http://clouddata.cloud.suse.de/cgi-bin/apicheck";
my $obsapi = "api.opensuse.org";
my $apicheck="$apicheckcgi/$obsapi/build/$obsproject/SLE_11_SP2/x86_64";

foreach my $testtype (keys %{$uttrigger})
{
  foreach my $package (keys $uttrigger->{$testtype})
  {
      my $jobname = "$testtype-$package-$subproject";
      my $jobenv = $uttrigger->{$testtype}->{$package}."\n$projectsource";
      open (my $FH, '>', "$jobname.config.xml") or die $@;
      select $FH;

print qq{<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description>Starts some services and triggers the cloud-$jobname
&lt;br /&gt;&#xd;
&lt;b&gt;Changes to this job ONLY via the &lt;i&gt;openstack-unittest.config.xml.pl&lt;/i&gt; tool from the automation repo.&lt;/b&gt;
</description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="hudson.scm.NullSCM"/>
  <assignedNode>openstack-unittest</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers class="vector">
    <org.jenkinsci.plugins.urltrigger.URLTrigger>
      <spec>*/10 * * * *</spec>
      <entries>
        <org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
          <url>$apicheck/$package</url>
          <proxyActivated>false</proxyActivated>
          <checkStatus>false</checkStatus>
          <statusCode>200</statusCode>
          <checkLastModificationDate>false</checkLastModificationDate>
          <inspectingContent>true</inspectingContent>
          <contentTypes>
            <org.jenkinsci.plugins.urltrigger.content.SimpleContentType/>
          </contentTypes>
        </org.jenkinsci.plugins.urltrigger.URLTriggerEntry>
      </entries>
      <labelRestriction>false</labelRestriction>
    </org.jenkinsci.plugins.urltrigger.URLTrigger>
  </triggers>
  <concurrentBuild>false</concurrentBuild>
  <builders/>
  <publishers>
    <hudson.plugins.parameterizedtrigger.BuildTrigger>
      <configs>
        <hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
          <configs>
            <hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
              <properties>$jobenv</properties>
            </hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
          </configs>
          <projects>openstack-unittest, </projects>
          <condition>SUCCESS</condition>
          <triggerWithNoParameters>false</triggerWithNoParameters>
        </hudson.plugins.parameterizedtrigger.BuildTriggerConfig>
      </configs>
    </hudson.plugins.parameterizedtrigger.BuildTrigger>
  </publishers>
  <buildWrappers/>
</project>

};

    select STDOUT;
    close $FH;

    my $updatestr = 'curl -X POST --data-binary @'."$jobname.config.xml http://river.suse.de/job/cloud-$jobname-trigger/config.xml";
    my $createstr = 'curl -H "Content-Type: text/xml" -X POST --data-binary @'."$jobname.config.xml http://river.suse.de/createItem?name=cloud-$jobname-trigger";

    if ($upload)
    {
      my $err=0;
      print "Updating $jobname...";
      if (! system($updatestr) == 0)
      {
        print "Error - trying to create job\n";
        print "Creating $jobname...";
        if (! system($createstr) == 0)
        {
          print "Error - Could not update or create job: $jobname\n";
        }
      } else {
        system("rm -f $jobname.config.xml");
      }
      print "done\n";

    } else {
      push @output_update, $updatestr;
      push @output_create, $createstr;
    }
  }
}

if (! $upload)
{
  print "\nConfigs created locally\n";
  print "Please update the jenkins config by running these commands:\n";

  print "_Update_ the jobs with these commands:\n";
  print join("\n", @output_update)."\n";
  print "----------------------\n";
  print "_Create_ the jobs with these commands:\n";
  print join("\n", @output_create)."\n";
}
{'fraction_non_alphanumeric': 0.14806999032796975, 'fraction_numerical': 0.0031653917172250064, 'mean_word_length': 3.2872220128156804, 'pattern_counts': {'":': 0, '<': 145, '<?xml version=': 2, '>': 193, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 15}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6979880', 'n_tokens_mistral': 3775, 'n_tokens_neox': 3632, 'n_words': 587}