Skip to content

Commit

Permalink
Remove commented, unused and unreachable code (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomshutt authored Jul 4, 2022
1 parent a9fc9c2 commit 5774cd4
Show file tree
Hide file tree
Showing 21 changed files with 1 addition and 816 deletions.
4 changes: 0 additions & 4 deletions apis/mist/mist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
const httpTimeout = 2 * time.Second

var httpClient = &http.Client{
// Transport: &http2.Transport{TLSClientConfig: tlsConfig},
// Transport: &http2.Transport{AllowHTTP: true},
// Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, AllowHTTP: true},
Timeout: httpTimeout,
}

Expand Down Expand Up @@ -317,7 +314,6 @@ func (mapi *API) CreateStream(name string, presets []string, profiles []Profile,
Name: name,
Source: source,
Segmentsize: segmentSize,
// Processes: []*Process{{Process: "Livepeer", AccessToken: mapi.livepeerToken, TargetProfiles: targetProfiles, Leastlive: "1", CustomURL: customURL}},
}
if !skipTranscoding {
audioSelect := ""
Expand Down
13 changes: 0 additions & 13 deletions cmd/api-transcoder/api-transcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,7 @@ func transcode(apiKey, apiHost, src, dst string, presets []string, lprofile *liv

func main() {
flag.Set("logtostderr", "true")
// flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
// flag.Parse()
flag.CommandLine.Parse(nil)
/*
vFlag := flag.Lookup("v")
verbosity := "6"
flag.CommandLine.Parse(nil)
vFlag.Value.Set(verbosity)
*/
// var echoTimes int
var apiKey, apiHost string
var presets string
var resolution, frameRate, profile string
Expand All @@ -246,7 +236,6 @@ func main() {
Long: `Transcodes video file using Livepeer API.`,
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
// fmt.Println("transcode: " + strings.Join(args, " "))
var err error
inp := args[0]
inpExt := filepath.Ext(inp)
Expand Down Expand Up @@ -275,8 +264,6 @@ func main() {
os.Exit(1)
}
fmt.Printf("api key %q transcode from %q to %q\n", apiKey, inp, output)
// presets := []string{"P144p30fps16x9", "P240p30fps4x3"}
// ffmpeg.P720p30fps16x9
var presetsAr []string
if len(presets) > 0 {
presetsAr = strings.Split(presets, ",")
Expand Down
30 changes: 0 additions & 30 deletions cmd/eapi/eapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,18 @@ import (
"flag"
"fmt"
"log"
"net/http"
"os"
"runtime"
"strings"
"time"

"github.com/livepeer/stream-tester/apis/etcd"
"github.com/livepeer/stream-tester/apis/livepeer"
"github.com/livepeer/stream-tester/internal/utils"
"github.com/livepeer/stream-tester/model"
"github.com/peterbourgon/ff/v2/ffcli"
clientv3 "go.etcd.io/etcd/client/v3"
"golang.org/x/net/http2"
)

const httpTimeout = 16 * time.Second

var httpClient = &http.Client{
Timeout: httpTimeout,
}

var http2Client = &http.Client{
Transport: &http2.Transport{},
Timeout: httpTimeout,
}

var server = livepeer.ACServer

func main() {
flag.Set("logtostderr", "true")
vFlag := flag.Lookup("v")
Expand All @@ -45,11 +29,6 @@ func main() {
etcdKey := rootFlagSet.String("key", "", "ETCD client certificate key file name")
endpoints := strings.Split(*endpointsF, ",")

// token := rootFlagSet.String("token", "", "Livepeer API's access token")
// presets := rootFlagSet.String("presets", "P240p30fps16x9", "Transcoding profiles")
// fServer := rootFlagSet.String("server", livepeer.ACServer, "API server to use")
// streamID := rootFlagSet.String("stream-id", "", "ID of existing stream to use for transcoding")

put := &ffcli.Command{
Name: "put",
ShortUsage: "lapi put key_name key_value",
Expand All @@ -73,10 +52,8 @@ func main() {
} else {
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
txn := eapi.Client.Txn(ctx)
// fmt.Printf("txt %+v", txn)
cmp := clientv3.Compare(clientv3.CreateRevision(args[0]), "=", 0)
cmp = clientv3.Compare(clientv3.CreateRevision(args[0]), ">", -1)
// put := clientv3.OpPut(args[0], args[1], clientv3.WithLease(s.Lease()))
put := clientv3.OpPut(args[0], args[1])
// reuse key in case this session already holds the lock
get := clientv3.OpGet(args[0])
Expand Down Expand Up @@ -136,7 +113,6 @@ func main() {
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
var opts []clientv3.OpOption
// x := clientv3.WithRev(presp.Header.Revision)
if len(args) > 1 {
opts = append(opts, clientv3.WithRange(args[1]))
} else {
Expand All @@ -151,8 +127,6 @@ func main() {
fmt.Printf("No keys found for %s\n", key)
}
for _, ev := range resp.Kvs {
// fmt.Printf("%s : %s CreateRevision: %d ModRevision %d Version %d\n", ev.Key, ev.Value, ev.CreateRevision,
// ev.ModRevision, ev.Version)
fmt.Printf("'%s' CreateRevision: %d ModRevision %d Version %d\n", ev.Key, ev.CreateRevision,
ev.ModRevision, ev.Version)
}
Expand All @@ -166,9 +140,6 @@ func main() {
Subcommands: []*ffcli.Command{put, ls, del},
}

// if err := root.ParseAndRun(context.Background(), os.Args[1:]); err != nil {
// log.Fatal(err)
// }
if err := root.Parse(os.Args[1:]); err != nil {
log.Fatal(err)
}
Expand All @@ -178,7 +149,6 @@ func main() {
fmt.Println("eapi version: " + model.Version)
fmt.Printf("Compiler version: %s %s\n", runtime.Compiler, runtime.Version())
fmt.Printf("Hostname %s OS %s IPs %v\n", hostName, runtime.GOOS, utils.GetIPs())
// flag.Parse()

if err := root.Run(context.Background()); err != nil {
log.Fatal(err)
Expand Down
6 changes: 0 additions & 6 deletions cmd/mapi/mapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/livepeer/stream-tester/internal/utils/uhttp"
"github.com/livepeer/stream-tester/model"
"github.com/peterbourgon/ff/v2/ffcli"
"golang.org/x/net/http2"
)

const httpTimeout = 16 * time.Second
Expand All @@ -30,11 +29,6 @@ var httpClient = &http.Client{
Timeout: httpTimeout,
}

var http2Client = &http.Client{
Transport: &http2.Transport{},
Timeout: httpTimeout,
}

func main() {
flag.Set("logtostderr", "true")
vFlag := flag.Lookup("v")
Expand Down
3 changes: 0 additions & 3 deletions cmd/orch-tester/broadcaster_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ func (bm *broadcasterMetrics) avg(m string) float64 {
}

func (bm *broadcasterMetrics) errorCount() map[string]int {
bm.mu.Lock()
bm.mu.Unlock()

res := map[string]int{}
for key, value := range bm.incErrs {
res[key] = value
Expand Down
52 changes: 0 additions & 52 deletions cmd/streamtester/streamtester.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func main() {
apiToken := flag.String("api-token", "", "Token of the Livepeer API to be used by the Mist server")
apiServer := flag.String("api-server", "livepeer.com", "Server of the Livepeer API to be used")
lapiFlag := flag.Bool("lapi", false, "Use Livepeer API to create streams. api-token should be specified")
presets := flag.String("presets", "", "Comma separate list of transcoding profiels to use along with Livepeer API")
skipTime := flag.Duration("skip-time", 0, "Skips first x(s|m)")
picartoFlag := flag.Bool("picarto", false, "Do Picarto-pull testing")
adult := flag.Bool("adult", false, "Adult Picarto")
Expand Down Expand Up @@ -110,16 +109,12 @@ func main() {
fmt.Printf("Production: %v\n", model.Production)

if *version {
// fmt.Println("Stream tester version: " + model.Version)
// fmt.Printf("Compiler version: %s %s\n", runtime.Compiler, runtime.Version())
return
}
if *latencyThreshold > 0 {
*latency = true
}
metrics.InitCensus(hostName, model.Version, "streamtester")
// codec.MTest()
// return
gctx, gcancel := context.WithCancel(context.Background()) // to be used as global parent context, in the future
messenger.Init(gctx, *discordURL, *discordUserName, *discordUsersToNotify, *botToken, *channelID, *apiToken)
defer time.Sleep(2 * time.Second)
Expand Down Expand Up @@ -153,12 +148,7 @@ func main() {
testers.IgnoreNoCodecError = true
testers.IgnoreTimeDrift = true
}
// puller := testers.NewInfinitePuller(gctx, *infinitePull, *save, *wowza, *mist)
// puller.Start()
glog.Infof(`Starting infinite pull from %s`, *infinitePull)
// messenger.SendMessage(msg)
// sr2 := testers.NewStreamer2(gctx, *wowza, *mist)
// sr2.StartPulling(*mediaURL)
started := time.Now()
var wg sync.WaitGroup
for i := 0; i < int(*sim); i++ {
Expand Down Expand Up @@ -225,8 +215,6 @@ func main() {

mc := testers.NewMistController(*bhost, int(*picartoStreams), *profiles, *adult, *gaming, *save, mapi,
*picartoBlackList, *picartoExternalHost, *picartoStatsInterval, *picartoSDCutOff, *picartoCountry)
// emsg := fmt.Sprintf("Starting **%d** Picarto streams (ver %s)", *picartoStreams, model.Version)
// messenger.SendMessage(emsg)
go startWebServer() // needed for /metrics endpoint

err = mc.Start()
Expand All @@ -242,26 +230,9 @@ func main() {
time.Sleep(time.Second)
return
}
// var streamDuration time.Duration
// if *stime != "" {
// if streamDuration, err = server.ParseStreamDurationArgument(*stime); err != nil {
// panic(err)
// }
// if *repeat > 1 {
// // glog.Fatal("Can't set both -time and -repeat.")
// }
// }

if *mediaURL != "" && *rtmpURL == "" {
glog.Fatal("Should also specifiy -rtmp-url")
// glog.Infof(`Starting infinite pull from %s`, *mediaURL)
// messenger.SendMessage(msg)
// sr2 := testers.NewStreamer2(gctx, *wowza, *mist)
// sr2.StartPulling(*mediaURL)
// started := time.Now()
// downloader := testers.NewM3utester2(gctx, *mediaURL, *wowza, *mist, *save, 15*time.Second, nil) // starts to download at creation
// <-downloader.Done()
// glog.Infof(`Streaming stopped after %s`, time.Since(started))
return
}
if *rtmpURL != "" {
Expand All @@ -285,9 +256,6 @@ func main() {
stats, _ := sr2.Stats()
fmt.Printf("Stats: %+v\n", stats)
os.Exit(model.ExitCode)
// to not exit
// s := server.NewStreamerServer(*wowza)
// s.StartWebServer("localhost:7933")
return
}

Expand All @@ -311,25 +279,13 @@ func main() {

mapi = mistapi.NewMist(*bhost, mcreds[0], mcreds[1], *apiToken, *mistPort)
mapi.Login()
// mapi.CreateStream("dark1", "P720p30fps16x9")
// mapi.DeleteStreams("dark1")
}
if *lapiFlag {
if *apiToken == "" {
glog.Fatalf("-api-token should be specified")
}
if !*httpIngest {
// glog.Fatal("Using Livepeer API currently only implemented for HTTP ingest")
// glog.Fatal("Using Livepeer API currently only implemented for RTMP ingest")
// API webhook doesn't authenicate RTMP streams
}
if *presets == "" {
// glog.Fatal("Presets should be specified")
}
go startWebServer() // needed for /metrics endpoint
hostName, _ := os.Hostname()
// presetsParts := strings.Split(*presets, ",")
// model.ProfilesNum = len(presetsParts)
lapi = livepeer.NewLivepeer(*apiToken, *apiServer, nil)
lapi.Init()
glog.Infof("Choosen server: %s", lapi.GetServer())
Expand Down Expand Up @@ -386,7 +342,6 @@ func main() {
os.Exit(model.ExitCode)
return
}
// fmt.Printf("Args: %+v\n", flag.Args())
glog.Infof("Starting stream tester %s, file %s number of streams is %d, repeat %d times no bar %v", model.Version, fn, *sim, *repeat, *noBar)

defer glog.Infof("Exiting")
Expand All @@ -406,14 +361,9 @@ func main() {
time.Sleep(25 * time.Second)
stats, _ := sr.Stats("")
fmt.Println(stats.FormatForConsole())
// fmt.Println(sr.DownStatsFormatted())
}
}()
}
// go func() {
// time.Sleep(10 * time.Second)
// sr.Cancel()
// }()
// Catch interrupt signal to shut down transcoder
glog.Infof("Waiting for test to complete")
<-sr.Done()
Expand All @@ -438,7 +388,6 @@ func main() {
}
}

// fmt.Println(sr.AnalyzeFormatted(false))
if *latencyThreshold > 0 && stats.TranscodedLatencies.P95 > 0 {
// check latencies, report failure or success
var msg string
Expand All @@ -456,5 +405,4 @@ func main() {
s := server.NewStreamerServer(*wowza, "", "", *mistPort)
s.StartWebServer(gctx, *serverAddr)
}
// messenger.SendMessage(sr.AnalyzeFormatted(true))
}
1 change: 0 additions & 1 deletion internal/app/mistapiconnector/mistapiconnector_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const traefikKeyPathRouters = `traefik/http/routers/`
const traefikKeyPathServices = `traefik/http/services/`
const traefikKeyPathMiddlewares = `traefik/http/middlewares/`
const audioAlways = "always"
const audioNever = "never"
const audioRecord = "record"
const audioEnabledStreamSuffix = "rec"
const etcdDialTimeout = 5 * time.Second
Expand Down
10 changes: 0 additions & 10 deletions internal/app/vodtester/continuous_vod_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/url"
"strconv"
"time"

"github.com/PagerDuty/go-pagerduty"
Expand Down Expand Up @@ -144,12 +143,3 @@ func (cvt *continuousVodTester) Cancel() {
func (cvt *continuousVodTester) Done() <-chan struct{} {
return cvt.ctx.Done()
}

var nth = []string{"0", "first", "second", "third", "forth", "fifth"}

func getNth(i int) string {
if i > 0 && i < len(nth) {
return nth[i]
}
return strconv.Itoa(i)
}
5 changes: 0 additions & 5 deletions internal/metrics/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import (
"go.opencensus.io/tag"
)

const (
logLevel = 6 // TODO move log levels definitions to separate package
// importing `common` package here introduces import cycles
)

type (
censusMetricsCounter struct {
nodeID string
Expand Down
2 changes: 0 additions & 2 deletions internal/testers/http_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ type httpStreamer struct {

type httpStats struct {
triedToSend int
sent int
failedToSend int
downloaded int
downloadFailures int
transcodeFailures int
success int
Expand Down
Loading

0 comments on commit 5774cd4

Please sign in to comment.