Add google cloud VM regressions scripts

This commit is contained in:
Dolu1990 2018-07-07 21:47:09 +02:00
parent ce54fd78e4
commit 32fe1dcbd4
7 changed files with 96 additions and 21 deletions

1
src/test/python/gcloud/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/gcloud.pyc

View File

@ -0,0 +1,51 @@
#!/usr/bin/env python
from os import system
from sys import argv
import time
class GCInstance:
def __init__(self, name):
self.instance = name
self.project = "ivory-infusion-209508"
self.zone = "europe-west1-b"
def local(self, cmd):
print(cmd)
system(cmd)
def createCustom(self, cores=1, ram=1024):
self.create("custom-{}-{}".format(cores,ram))
#n1-highcpu-8
def create(self, machine="f1-micro"):
self.delete()
self.local('gcloud beta compute --project=ivory-infusion-209508 instances create {} --zone=europe-west1-b --machine-type={} --subnet=default --network-tier=PREMIUM --no-restart-on-failure --maintenance-policy=TERMINATE --preemptible --service-account=470010940365-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --disk=name=miaou,device-name=miaou,mode=rw,boot=yes'.format(self.instance, machine))
def start(self):
self.local('gcloud compute --project "{}" instances start --zone "{}" "{}"'.format(self.project, self.zone, self.instance)) # --machine-type=f1-micro
time.sleep(60)
def stopHours(self, hours):
self.remote('sudo shutdown -P +{}'.format(int(hours*60)))
def stop(self):
self.remote('sudo shutdown -P now')
def delete(self):
self.local('gcloud compute --project "{}" instances delete "{}" --zone "{}" --keep-disks all --quiet'.format(self.project, self.instance, self.zone))
def remote(self, cmd):
self.local('gcloud compute --project "{}" ssh --zone "{}" "{}" -- "{}"'.format(self.project, self.zone, self.instance, cmd))
def localToRemote(self, source, target):
self.remote("rm -rf {}".format(target))
self.local('gcloud compute --project "{}" scp --zone "{}" {} {}:{}'.format(self.project, self.zone, source, self.instance, target))
def remoteToLocal(self, source, target):
self.remote("rm -rf {}".format(target))
self.local('gcloud compute --project "{}" scp --zone "{}" {}:{} {}'.format(self.project, self.zone, self.instance, source, target))
#setsid nohup (sbt test;sudo poweroff) &> sbtTest.txt

View File

View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
from gcloud import GCInstance
gci = GCInstance("vexriscv")
gci.create()
gci.start()
gci.remoteToLocal("VexRiscv/sbtTest.txt","sbtTest.txt")
gci.stop()
gci.delete()

View File

@ -3,21 +3,16 @@
from os import system from os import system
from sys import argv from sys import argv
def remote(cmd): from gcloud import GCInstance
cmd = "gcloud compute ssh miaou -- '" + cmd + "'"
print(cmd)
system(cmd)
def localToRemote(source, target): gci = GCInstance("vexriscv")
remote("rm -rf target") gci.create("n1-highcpu-8")
cmd = "gcloud compute scp " + source + " miaou:" + target gci.start()
print(cmd) gci.stopHours(20)
system(cmd)
system("gcloud compute instances create miaou --machine-type=f1-micro") gci.local("rm -rf archive.tar.gz; git ls-files -z | xargs -0 tar -czf archive.tar.gz")
system("rm -rf archive.tar.gz; git ls-files -z | xargs -0 tar -czf archive.tar.gz") gci.localToRemote("archive.tar.gz", "")
localToRemote("archive.tar.gz", "") gci.localToRemote("src/test/python/gcloud/run.sh", "")
remote("tar -xzf archive.tar.gz") gci.remote("rm -rf run.txt; setsid nohup sh run.sh &> run.txt")
remote("mkdir z;cd z; pwd")
remote("pwd")
#setsid nohup (sbt test;sudo poweroff) &> sbtTest.txt

View File

@ -0,0 +1,18 @@
rm -rf sbtTest.txt
rm -rf VexRiscv
mkdir VexRiscv
tar -xzf archive.tar.gz -C VexRiscv
cd VexRiscv
export VEXRISCV_REGRESSION_CONFIG_COUNT=16
export VEXRISCV_REGRESSION_FREERTOS_COUNT=yes
sbt test
cd ..
#sudo apt-get install mailutils + https://cloud.google.com/compute/docs/tutorials/sending-mail/using-mailgun
echo "Miaou" | mail -s "VexRiscv cloud" charles.papon.90@gmail.com -A run.txt
sleep 15
sudo shutdown -P now

View File

@ -457,7 +457,7 @@ class TestIndividualFeatures extends FunSuite {
new HazardDimension, new HazardDimension,
new RegFileDimension, new RegFileDimension,
new SrcDimension, new SrcDimension,
new CsrDimension(sys.env.getOrElse("VEXRISCV_FREERTOS", "4")), new CsrDimension(sys.env.getOrElse("VEXRISCV_REGRESSION_FREERTOS_COUNT", "4")),
new DecoderDimension, new DecoderDimension,
new DebugDimension new DebugDimension
) )
@ -494,7 +494,7 @@ class TestIndividualFeatures extends FunSuite {
test(prefix + name + "_test") { test(prefix + name + "_test") {
val debug = false val debug = false
val stdCmd = (if(debug) "make clean run REDO=1 TRACE=yes TRACE_ACCESS=yes MMU=no STOP_ON_ERROR=yes DHRYSTONE=no THREAD_COUNT=1 TRACE_START=0 " else "make clean run REDO=10 TRACE=no MMU=no THREAD_COUNT=4 ") + s" SEED=${testSeed} " val stdCmd = (if(debug) "make clean run REDO=1 TRACE=yes TRACE_ACCESS=yes MMU=no STOP_ON_ERROR=yes DHRYSTONE=no THREAD_COUNT=1 TRACE_START=0 " else s"make clean run REDO=10 TRACE=no MMU=no THREAD_COUNT=${sys.env.getOrElse("VEXRISCV_REGRESSION_THREAD_COUNT", Runtime.getRuntime().availableProcessors().toString)} ") + s" SEED=${testSeed} "
// val stdCmd = "make clean run REDO=40 DHRYSTONE=no STOP_ON_ERROR=yes TRACE=yess MMU=no" // val stdCmd = "make clean run REDO=40 DHRYSTONE=no STOP_ON_ERROR=yes TRACE=yess MMU=no"
val testCmd = stdCmd + (positionsToApply).map(_.testParam).mkString(" ") val testCmd = stdCmd + (positionsToApply).map(_.testParam).mkString(" ")
@ -508,12 +508,12 @@ class TestIndividualFeatures extends FunSuite {
// dimensions.foreach(d => d.positions.foreach(p => p.dimension = d)) // dimensions.foreach(d => d.positions.foreach(p => p.dimension = d))
val testId : Option[mutable.HashSet[Int]] = None val testId : Option[mutable.HashSet[Int]] = None
// val seed = Random.nextLong() val seed = Random.nextLong()
// val testId = Some(mutable.HashSet(18,34,77,85,118,129,132,134,152,167,175,188,191,198,199)) //37/29 sp_flop_rv32i_O3 // val testId = Some(mutable.HashSet(18,34,77,85,118,129,132,134,152,167,175,188,191,198,199)) //37/29 sp_flop_rv32i_O3
//val testId = Some(mutable.HashSet(18)) //val testId = Some(mutable.HashSet(18))
// val testId = Some(mutable.HashSet(129, 134)) // val testId = Some(mutable.HashSet(129, 134))
val seed = -2412372746600605141l // val seed = -2412372746600605141l
// val testId = Some(mutable.HashSet(1)) // val testId = Some(mutable.HashSet(1))
@ -522,10 +522,10 @@ class TestIndividualFeatures extends FunSuite {
val rand = new Random(seed) val rand = new Random(seed)
test("Info"){ test("Info"){
println(seed) println(S"MAIN_SEED=$seed")
} }
println(s"Seed=$seed") println(s"Seed=$seed")
for(i <- 0 until 200){ for(i <- 0 until sys.env.getOrElse("VEXRISCV_REGRESSION_CONFIG_COUNT", "200").toInt){
var positions : List[VexRiscvPosition] = null var positions : List[VexRiscvPosition] = null
val universe = VexRiscvUniverse.universes.filter(e => rand.nextBoolean()) :+ VexRiscvUniverse.CATCH_ALL //TODO val universe = VexRiscvUniverse.universes.filter(e => rand.nextBoolean()) :+ VexRiscvUniverse.CATCH_ALL //TODO