Skip to content

Commit

Permalink
add slowstart code
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Nov 1, 2023
1 parent 536cc18 commit 75701f2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test_images/slowstart/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2023 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"
"fmt"
"log"
"time"
)

func main() {
sleep := flag.Int("sleep", 0, "Time to sleep in seconds")
flag.Parse()

duration, err := time.ParseDuration(fmt.Sprintf("%ds", *sleep))
if err != nil {
log.Fatalf("Could not parse duration: %d, err: %v", *sleep, err)
}
time.Sleep(duration)

log.Printf("Sleept for: %ds", *sleep)
}
24 changes: 24 additions & 0 deletions test/test_images/slowstart/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: slow-start
namespace: default
spec:
template:
spec:
containers:
- image: ko://knative.dev/serving/test/test_images/slowstart

0 comments on commit 75701f2

Please sign in to comment.