Exemple #1
0
func SetupRedis() *redis.Pool {
	maxConnections := envflag.Int("REDIS_MAX_CONNECTIONS", 400, "Maximum ammount of concurrent Redis connections")
	redisURL := envflag.String("REDIS_URL", "redis://localhost:6379", "Redis database url")

	envflag.Parse()

	pool, err := redisurl.NewPoolWithURL(*redisURL, 3, *maxConnections, "240s")
	if err != nil {
		panic(err)
	}

	return pool
}
Exemple #2
0
func main() {
	var (
		hostport     = envflag.String("SHEEPDOG_HOSTPORT", "", "host:port pair for sheepdog cluster")
		readHostPort = envflag.String("SHEEPDOG_READ_HOSTPORT", "", "host:port pair for only issuing reads to sheepdog cluster")
		readDelay    = envflag.Duration("SHEEPDOG_READ_SLEEP", 0, "time to sleep between each read of test")
		payloadCount = envflag.Int("SHEEPDOG_TEST_PAYLOAD_COUNT", 10, "payload count to issue reads and writes to sheepdog")
		vdiSize      = envflag.Int("SHEEPDOG_VDI_SIZE", 1<<22, "create vdi of given size")
		vdiName      = envflag.String("SHEEPDOG_VDI_NAME", "testvdi", "name of vdi to test read/writes across")
	)
	envflag.Parse()

	c, err := picard.NewCluster(*hostport)
	if err != nil {
		log.Fatalln(err)
	}
	log.Printf("Created connection to sheepdog successfully")

	defer func() {
		if err := c.Disconnect(); err != nil {
			log.Fatalln(err)
		}
		log.Printf("Successfully disconnected!")
	}()

	vdi, err := c.CreateOpenVDI(*vdiName, uint64(*vdiSize))
	if err != nil {
		log.Fatalln(err)
	}
	log.Printf("Created and opened VDI successfully")

	defer func() {
		vdi.Close()
		if err := c.DeleteVDI(vdi.Name()); err != nil {
			log.Fatalln(err)
		}
		log.Printf("Successfully deleted vdi: %q", vdi.Name())
	}()

	rvdi := vdi
	if *readHostPort != "" {
		rc, err := picard.NewCluster(*readHostPort)
		if err != nil {
			log.Fatalln(err)
		}
		log.Printf("Created read connection to sheepdog successfully")

		defer func() {
			if err := rc.Disconnect(); err != nil {
				log.Fatalln(err)
			}
			log.Printf("Successfully disconnected for read connection!")
		}()

		rvdi, err = rc.OpenVDI(*vdiName)
		if err != nil {
			log.Fatalln(err)
		}
		log.Printf("Opened VDI successfully for reads")

		defer rvdi.Close()
	}

	vdiChan := make(chan *vdiData)

	go func() {
		if count, err := writeToVDI(vdi, vdiChan, *payloadCount); err != nil {
			log.Printf("Error while writing at %d: %s", count, err)
		}
	}()

	if count, failed, err := readFromVDI(rvdi, vdiChan, *readDelay); err != nil {
		log.Printf("Error occurred during reads:\n\tTotal: %d, Failures: %d\n\tError: %q", count, failed, err)
	}
}
Exemple #3
0
	Pattern         string `json:"pattern"           toml:"pattern"`
	Team            string `json:"team"              toml:"team"`
	SelfApprovalOff bool   `json:"self_approval_off" toml:"self_approval_off"`
	DoMerge         bool   `json:"do_merge" toml:"do_merge"`
	DoVersion       bool   `json:"do_version" toml:"do_version"`
	ApprovalAlg     string `json:"approval_algorithm" toml:"approval_algorithm"`
	VersionAlg      string `json:"version_algorithm" toml:"version_algorithm"`
	VersionFormat   string `json:"version_format" toml:"version_format"`
	DoComment       bool   `json:"do_comment" toml:"do_comment"`
	DoDeployment    bool   `json:"do_deploy" toml:"do_deploy"`
	DeploymentMap   DeploymentConfigs
	re              *regexp.Regexp
}

var (
	approvals       = envflag.Int("LGTM_APPROVALS", 2, "")
	pattern         = envflag.String("LGTM_PATTERN", `(?i)^LGTM\s*(\S*)`, "")
	team            = envflag.String("LGTM_TEAM", "MAINTAINERS", "")
	selfApprovalOff = envflag.Bool("LGTM_SELF_APPROVAL_OFF", false, "")
	approvalAlg     = envflag.String("LGTM_APPROVAL_ALGORITHM", "simple", "")
	versionAlg      = envflag.String("LGTM_VERSION_ALGORITHM", "semver", "")
)

// ParseConfig parses a projects .lgtm file
func ParseConfig(configData []byte, deployData []byte) (*Config, error) {
	c, err := ParseConfigStr(string(configData))
	if err != nil {
		return nil, err
	}
	if c.DoDeployment {
		c.DeploymentMap, err = loadDeploymentMap(string(deployData))