...

Source file src/github.com/chaos-mesh/chaos-mesh/e2e-test/e2e/chaos/testcasetemplate/template.go

Documentation: github.com/chaos-mesh/chaos-mesh/e2e-test/e2e/chaos/testcasetemplate

     1  // Copyright 2021 Chaos Mesh Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  // http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  //
    15  
    16  package testcasetemplate
    17  
    18  import (
    19  	. "github.com/onsi/ginkgo/v2"
    20  	"k8s.io/client-go/kubernetes"
    21  	"sigs.k8s.io/controller-runtime/pkg/client"
    22  )
    23  
    24  func TestcaseTemplate(
    25  	ns string,
    26  	kubeCli kubernetes.Interface,
    27  	cli client.Client,
    28  	// any other parameters that you need fetch from context
    29  ) {
    30  	// describe test steps with By() statement
    31  	// here are some examples.
    32  	By("preparing experiment pods")
    33  	// some logic to create pod which will be injected chaos
    34  	By("create pod failure chaos CRD objects")
    35  	// create chaos CRD
    36  	By("waiting for assertion some pod fall into failure")
    37  	// assert that chaos is effective
    38  	By("delete pod failure chaos CRD objects")
    39  	// delete chaos CRD
    40  	By("waiting for assertion recovering")
    41  	// assert that chaos has gone
    42  }
    43