From 53ac288150d7e51f63fc7b7d4efb14620ca6457f Mon Sep 17 00:00:00 2001 From: Nick Nellis Date: Wed, 7 Jul 2021 10:13:03 -0500 Subject: [PATCH] randomize the number of tiers per namespace --- cmd/generate.go | 4 ++-- pkg/generate/gen.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/generate.go b/cmd/generate.go index c329bd8..4c6eca5 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -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, @@ -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") } diff --git a/pkg/generate/gen.go b/pkg/generate/gen.go index c0d1688..1b9defc 100644 --- a/pkg/generate/gen.go +++ b/pkg/generate/gen.go @@ -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