55package cmd
66
77import (
8+ "crypto/tls"
9+ "crypto/x509"
810 "encoding/json"
11+ "io/ioutil"
912 "os"
1013 "os/signal"
14+ "path/filepath"
1115 "syscall"
1216 "time"
1317
1418 "github.com/golang/protobuf/ptypes"
1519 log "github.com/sirupsen/logrus"
1620 "github.com/spf13/cobra"
1721 "google.golang.org/grpc"
22+ "google.golang.org/grpc/credentials"
1823
1924 csapi "github.com/gitpod-io/gitpod/content-service/api"
2025 "github.com/gitpod-io/gitpod/loadgen/pkg/loadgen"
2126 "github.com/gitpod-io/gitpod/loadgen/pkg/observer"
2227 "github.com/gitpod-io/gitpod/ws-manager/api"
2328)
2429
30+ var runOpts struct {
31+ TLSPath string
32+ }
33+
2534// runCmd represents the run command
2635var runCmd = & cobra.Command {
2736 Use : "run" ,
2837 Short : "runs the load generator" ,
2938 Run : func (cmd * cobra.Command , args []string ) {
30- const workspaceCount = 100
39+ const workspaceCount = 500
3140
3241 var load loadgen.LoadGenerator
3342 load = loadgen .NewFixedLoadGenerator (500 * time .Millisecond , 300 * time .Millisecond )
@@ -42,7 +51,7 @@ var runCmd = &cobra.Command{
4251 },
4352 ServicePrefix : "will-be-overriden" ,
4453 Spec : & api.StartWorkspaceSpec {
45- IdeImage : "eu.gcr.io/gitpod-dev/theia-io- ide:master.2999 " ,
54+ IdeImage : "eu.gcr.io/gitpod-dev/ide/theia :master.3206 " ,
4655 Admission : api .AdmissionLevel_ADMIT_OWNER_ONLY ,
4756 CheckoutLocation : "gitpod" ,
4857 Git : & api.GitSpec {
@@ -54,7 +63,7 @@ var runCmd = &cobra.Command{
5463 Spec : & csapi.WorkspaceInitializer_Git {
5564 Git : & csapi.GitInitializer {
5665 CheckoutLocation : "" ,
57- CloneTaget : "master " ,
66+ CloneTaget : "main " ,
5867 RemoteUri : "https://github.com/gitpod-io/gitpod.git" ,
5968 TargetMode : csapi .CloneTargetMode_REMOTE_BRANCH ,
6069 Config : & csapi.GitConfig {
@@ -76,7 +85,29 @@ var runCmd = &cobra.Command{
7685 Type : api .WorkspaceType_REGULAR ,
7786 }
7887
79- conn , err := grpc .Dial ("localhost:8080" , grpc .WithInsecure ())
88+ var opts []grpc.DialOption
89+ if runOpts .TLSPath != "" {
90+ ca , err := ioutil .ReadFile (filepath .Join (runOpts .TLSPath , "ca.crt" ))
91+ if err != nil {
92+ log .Fatal (err )
93+ }
94+ capool := x509 .NewCertPool ()
95+ capool .AppendCertsFromPEM (ca )
96+ cert , err := tls .LoadX509KeyPair (filepath .Join (runOpts .TLSPath , "tls.crt" ), filepath .Join (runOpts .TLSPath , "tls.key" ))
97+ if err != nil {
98+ log .Fatal (err )
99+ }
100+ creds := credentials .NewTLS (& tls.Config {
101+ Certificates : []tls.Certificate {cert },
102+ RootCAs : capool ,
103+ ServerName : "ws-manager" ,
104+ })
105+ opts = append (opts , grpc .WithTransportCredentials (creds ))
106+ } else {
107+ opts = append (opts , grpc .WithInsecure ())
108+ }
109+
110+ conn , err := grpc .Dial ("localhost:8080" , opts ... )
80111 if err != nil {
81112 log .Fatal (err )
82113 }
@@ -124,4 +155,6 @@ var runCmd = &cobra.Command{
124155
125156func init () {
126157 rootCmd .AddCommand (runCmd )
158+
159+ runCmd .Flags ().StringVar (& runOpts .TLSPath , "tls" , "" , "path to ws-manager's TLS certificates" )
127160}
0 commit comments