Introduced cancel_all_bookings flag
diff --git a/README.md b/README.md index de53791..5deb718 100644 --- a/README.md +++ b/README.md
@@ -90,6 +90,14 @@ Whether to test the GetBookingStatus endpoint. -booking_test Whether to test the CreateBooking endpoint. + -ca_file string + Absolute path to your server's Certificate Authority root cert. + Downloading all roots currently recommended by the Google Internet + Authority is a suitable alternative https://pki.google.com/roots.pem + -cancel_all_bookings + This option assumes that the ListBookings and UpdateBooking endpoints + are fully functional. This is a convenience flag for purging your system + of all previously created bookings. -check_availability_test Whether to test the CheckAvailability endpoint. -health_check_test @@ -97,8 +105,8 @@ -list_bookings_test Whether to test the ListBookings endpoint -num_test_slots int - Maximum number of slots to test from availability_feed. - Slots will be selected randomly (default 10) + Maximum number of slots to test from availability_feed. Slots will be + selected randomly (default 10) -output_dir string Absolute path of dir to dump log file. -rescheduling_test @@ -106,8 +114,13 @@ -rpc_timeout duration Number of seconds to wait before abandoning request (default 30s) -server_addr string - Your grpc server's address in the format of - host:port (default "example.com:80") + Your grpc server's address in the format of host:port + (default "example.com:80") + -servername_override string + Override FQDN to use. Please see README for additional details + -tls + Whether to enable TLS when using the test client. Please review the + README.md before attempting to use this flag. Example Usage:
diff --git a/testclient/main.go b/testclient/main.go index 0ed4589..8f18633 100644 --- a/testclient/main.go +++ b/testclient/main.go
@@ -118,21 +118,22 @@ -----END RSA PRIVATE KEY-----` var ( - serverAddr = flag.String("server_addr", "example.com:80", "Your grpc server's address in the format of host:port") - rpcTimeout = flag.Duration("rpc_timeout", 30*time.Second, "Number of seconds to wait before abandoning request") - testSlots = flag.Int("num_test_slots", 10, "Maximum number of slots to test from availability_feed. Slots will be selected randomly") - allFlows = flag.Bool("all_tests", false, "Whether to test all endpoints.") - healthFlow = flag.Bool("health_check_test", false, "Whether to test the Health endpoint.") - checkFlow = flag.Bool("check_availability_test", false, "Whether to test the CheckAvailability endpoint.") - bookFlow = flag.Bool("booking_test", false, "Whether to test the CreateBooking endpoint.") - listFlow = flag.Bool("list_bookings_test", false, "Whether to test the ListBookings endpoint") - statusFlow = flag.Bool("booking_status_test", false, "Whether to test the GetBookingStatus endpoint.") - rescheduleFlow = flag.Bool("rescheduling_test", false, "Whether to test the UpdateBooking endpoint.") - availabilityFeed = flag.String("availability_feed", "", "Absolute path to availability feed required for all tests except health. Feeds can be in either json or pb3 format") - outputDir = flag.String("output_dir", "", "Absolute path of dir to dump log file.") - enableTLS = flag.Bool("tls", false, "Whether to enable TLS when using the test client. Please review the README.md before attempting to use this flag.") - caFile = flag.String("ca_file", "", "Absolute path to your server's Certificate Authority root cert. Downloading all roots currently recommended by the Google Internet Authority is a suitable alternative https://pki.google.com/roots.pem") - serverName = flag.String("servername_override", "", "Override FQDN to use. Please see README for additional details") + serverAddr = flag.String("server_addr", "example.com:80", "Your grpc server's address in the format of host:port") + rpcTimeout = flag.Duration("rpc_timeout", 30*time.Second, "Number of seconds to wait before abandoning request") + testSlots = flag.Int("num_test_slots", 10, "Maximum number of slots to test from availability_feed. Slots will be selected randomly") + allFlows = flag.Bool("all_tests", false, "Whether to test all endpoints.") + healthFlow = flag.Bool("health_check_test", false, "Whether to test the Health endpoint.") + checkFlow = flag.Bool("check_availability_test", false, "Whether to test the CheckAvailability endpoint.") + bookFlow = flag.Bool("booking_test", false, "Whether to test the CreateBooking endpoint.") + listFlow = flag.Bool("list_bookings_test", false, "Whether to test the ListBookings endpoint") + statusFlow = flag.Bool("booking_status_test", false, "Whether to test the GetBookingStatus endpoint.") + rescheduleFlow = flag.Bool("rescheduling_test", false, "Whether to test the UpdateBooking endpoint.") + cancelAllBookings = flag.Bool("cancel_all_bookings", false, "This option assumes that the ListBookings and UpdateBooking endpoints are fully functional. This is a convenience flag for purging your system of all previously created bookings.") + availabilityFeed = flag.String("availability_feed", "", "Absolute path to availability feed required for all tests except health. Feeds can be in either json or pb3 format") + outputDir = flag.String("output_dir", "", "Absolute path of dir to dump log file.") + enableTLS = flag.Bool("tls", false, "Whether to enable TLS when using the test client. Please review the README.md before attempting to use this flag.") + caFile = flag.String("ca_file", "", "Absolute path to your server's Certificate Authority root cert. Downloading all roots currently recommended by the Google Internet Authority is a suitable alternative https://pki.google.com/roots.pem") + serverName = flag.String("servername_override", "", "Override FQDN to use. Please see README for additional details") ) type counters struct { @@ -299,6 +300,11 @@ ctx := context.Background() + // Health check doesn't affect the cancel booking flow so we let it through. + if *cancelAllBookings && (*allFlows || *checkFlow || *bookFlow || *listFlow || *statusFlow || *rescheduleFlow) { + log.Fatal("cancel_all_bookings is not supported with other test flows") + } + // HealthCheck Flow if *healthFlow || *allFlows { stats.HealthCheckSuccess = true @@ -312,15 +318,18 @@ } } - // Build availablility records. - if *availabilityFeed == "" { - log.Fatal("please set availability_feed flag if you wish to test additional flows") + var av []*fpb.Availability + if !*cancelAllBookings { + // Build availablility records. + if *availabilityFeed == "" { + log.Fatal("please set availability_feed flag if you wish to test additional flows") + } + av, err = utils.AvailabilityFrom(*availabilityFeed, *testSlots) + if err != nil { + log.Fatal(err.Error()) + } + stats.TotalSlotsProcessed += len(av) } - av, err := utils.AvailabilityFrom(*availabilityFeed, *testSlots) - if err != nil { - log.Fatal(err.Error()) - } - stats.TotalSlotsProcessed += len(av) // AvailabilityCheck Flow if *checkFlow || *allFlows { @@ -361,8 +370,8 @@ } // ListBookings Flow - if *listFlow || *allFlows { - if len(b) == 0 { + if *listFlow || *allFlows || *cancelAllBookings { + if len(b) == 0 && !*cancelAllBookings { b = GenerateBookings(setTimeout(ctx), av, &stats, client) } utils.LogFlow("List Bookings", "Start")