Skip to content

Commit

Permalink
enable it in appveyour
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Costa authored and jmecosta committed Dec 13, 2015
1 parent d646ffb commit 52125ce
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 10 deletions.
23 changes: 22 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ install:
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
if (!(Test-Path -Path "C:\sonar-runner" )) {
(new-object System.Net.WebClient).DownloadFile(
'http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip',
'C:\sonar-runner-dist.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonar-runner-dist.zip", "C:\sonar-runner")
}
if (!(Test-Path -Path "C:\sonarqube-4.5.6" )) {
(new-object System.Net.WebClient).DownloadFile(
'https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-4.5.6.zip',
'C:\sonarqube-4.5.6.zip'
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sonarqube-4.5.6.zip", "C:\sonarqube-4.5.6")
}
- ps: |
If ($env:Platform -Match "x86") {
$env:PCRE_PLATFORM="Win32"
Expand All @@ -24,10 +38,15 @@ install:
$env:VCVARS_PLATFORM="amd64"
$env:LANG_PLATFORM="-x64"
}
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
- cmd: SET PATH=C:\maven\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;C:\sonar-runner\sonar-runner-2.4\bin;%PATH%
- cmd: SET SONARHOME=C:\sonarqube-4.5.6\sonarqube-4.5.6
- cmd: SET
build_script:
- C:\Python27\Scripts\pip.exe install requests
- C:\Python27\Scripts\pip.exe install behave
- C:\Python27\Scripts\pip.exe install colorama
- mvn clean install
- C:\Python27\Scripts\behave.exe
cache:
- C:\maven\
- C:\Users\appveyor\.m2
Expand All @@ -38,4 +57,6 @@ on_failure:
- ps: Get-ChildItem cxx-squid\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem cxx-checks\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem sonar-cxx-plugin\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem *_project_.log | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem C:\sonarqube-4.5.6\sonarqube-4.5.6\logs\* | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }

74 changes: 65 additions & 9 deletions integration-tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
from subprocess import Popen, PIPE, check_call
from common import analyselog, sonarlog

from tempfile import mkstemp
from shutil import move
from os import remove, close

SONAR_URL = "http://localhost:9000"
INDENT = " "
BASEDIR = os.path.dirname(os.path.realpath(__file__))
Expand Down Expand Up @@ -155,7 +159,7 @@ def start_sonar(sonarhome):
sys.stdout.write(INDENT + "starting SonarQube ... ")
sys.stdout.flush()
now = time.time()
Popen(start_script(sonarhome), stdout=PIPE, shell=os.name == "nt")
start_script(sonarhome)
if not wait_for_sonar(50, is_webui_up):
sys.stdout.write(RED + "FAILED\n" + RESET)
return False
Expand All @@ -167,8 +171,19 @@ def start_sonar(sonarhome):

def stop_sonar(sonarhome):
if platform.system() == "Windows":
sys.stdout.write(YELLOW + "Cannot stop SonarQube automaticly on Windows. Please do it manually.\n" + RESET)
return
if platform.machine() == "x86_64":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
elif platform.machine() == "i686":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
elif platform.machine() == "AMD64":
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "UninstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")

if not wait_for_sonar(30, is_webui_down):
sys.stdout.write(RED + "FAILED\n" + RESET)
return False

sys.stdout.write(INDENT + "stopping SonarQube ... ")
sys.stdout.flush()
Expand All @@ -185,24 +200,63 @@ class UnsupportedPlatform(Exception):
def __init__(self, msg):
super(UnsupportedPlatform, self).__init__(msg)


def replace(file_path, pattern, subst):
#Create temp file
fh, abs_path = mkstemp()
with open(abs_path,'w') as new_file:
with open(file_path) as old_file:
for line in old_file:
new_file.write(line.replace(pattern, subst))
close(fh)
#Remove original file
remove(file_path)
#Move new file
move(abs_path, file_path)

def start_script(sonarhome):
command = None

if platform.system() == "Linux":
script = linux_script(sonarhome)
if script:
command = [script, "start"]

Popen(command, stdout=PIPE, shell=os.name == "nt")
elif platform.system() == "Windows":
replace(os.path.join(sonarhome, "conf", "sonar.properties"), "#sonar.path.temp=temp", "sonar.path.temp=" + os.path.join(sonarhome,"temp"))

if platform.machine() == "x86_64":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n")
elif platform.machine() == "i686":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-32", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n" + RESET)
elif platform.machine() == "AMD64":
command = ["start", "cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartSonar.bat")]
sys.stdout.write(GREEN + "Install Service...\n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "InstallNTService.bat")]
check_call(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Install Service... Ok\n" + RESET)
sys.stdout.write(GREEN + "Start Service... \n")
command = ["cmd", "/c", os.path.join(sonarhome, "bin", "windows-x86-64", "StartNTService.bat")]
Popen(command, stdout=PIPE, shell=os.name == "nt")
sys.stdout.write(GREEN + "Start Service... Ok \n" + RESET)

sys.stdout.write(GREEN + "Start on windows done... Ok \n" + RESET)
elif platform.system() == "Darwin":
command = [os.path.join(sonarhome, "bin/macosx-universal-64/sonar.sh"), "start"]

Popen(command, stdout=PIPE, shell=os.name == "nt")
if command is None:
msg = "Dont know how to find the start script for the platform %s-%s" % (platform.system(), platform.machine())
raise UnsupportedPlatform(msg)
Expand All @@ -213,13 +267,15 @@ def start_script(sonarhome):
def stop_script(sonarhome):
command = None


if platform.system() == "Linux":
script = linux_script(sonarhome)
if script:
command = [script, "stop"]
elif platform.system() == "Darwin":
command = [os.path.join(sonarhome, "bin/macosx-universal-64/sonar.sh"), "stop"]

elif platform.system() == "Windows":
command = ["cmd", "/c", "dir"]
if command is None:
msg = "Dont know how to find the stop script for the platform %s-%s" % (platform.system(), platform.machine())
raise UnsupportedPlatform(msg)
Expand Down

0 comments on commit 52125ce

Please sign in to comment.