Skip to content

Commit

Permalink
Merge pull request #4 from nmnellis/random-tiers
Browse files Browse the repository at this point in the history
randomize the number of tiers per namespace
  • Loading branch information
nmnellis authored Jul 7, 2021
2 parents 5b3e765 + 53ac288 commit e326d0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func init() {
generateCmd.Flags().Int64Var(&cfg.Seed, "seed", 0, "Override random seed with static one (for deterministic outputs)")
generateCmd.Flags().IntVarP(&cfg.NumberOfNamespaces, "namespaces", "n", 1, "Number of namespaces to generate applications for")
generateCmd.Flags().IntVarP(&cfg.NumberOfTiers, "tiers", "t", 3, "Length of the application call stack per namespace ("+
"how many applications deep)")
"how many applications deep, randomly chosen per namespace 2 < x )")
generateCmd.Flags().IntVar(&cfg.MaxAppsPerTier, "apps-per-tier", 5, "Max amount of applications that can exist in a given tier. "+
"Will randomly pick between 1 < x")
generateCmd.Flags().IntVar(&cfg.ChanceOfVersions, "chance-version", 10,
Expand Down Expand Up @@ -79,6 +79,6 @@ func init() {
"90% of the requested calls should return within this range")
generateCmd.Flags().StringVar(&cfg.Timing99Percentile, "timing-99-percentile", "20ms",
"99% of the requested calls should return within this range")
generateCmd.Flags().StringVar(&cfg.UpstreamTimeout, "upstream-timeout", "2s",
generateCmd.Flags().StringVar(&cfg.UpstreamTimeout, "upstream-timeout", "30s",
"Maximum duration for upstream service requests")
}
6 changes: 3 additions & 3 deletions pkg/generate/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ func (a *AppGenerator) Generate() error {
for i := 1; i <= a.config.NumberOfNamespaces; i++ {
namespaceName := fmt.Sprintf("ns-%d", i)

// TODO right now its just easier to have 1 microservice entry point per namespace

// randomly select the number of tiers in this ns, 2 < max
numberOfTiers := rand.Intn(a.config.NumberOfTiers) + 2
// namespaces[namespaceName] =
// generate tiers in reverse order so we can connect them to parents
tiers := map[int][]*Microservice{}
for tier := a.config.NumberOfTiers; tier > 0; tier-- {
for tier := numberOfTiers; tier > 0; tier-- {

if tier == 1 {
// top tier
Expand Down

0 comments on commit e326d0e

Please sign in to comment.