diff --git a/Dockerfile b/Dockerfile index f9404368d..bdbc31edb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,12 +67,7 @@ RUN \ && cp cnf-certification-test/cnf-certification-test ${TNF_BIN_DIR} \ # copy the tnf command binary && cp tnf ${TNF_BIN_DIR} \ - # copy all of the chaos-test-files - && mkdir -p ${TNF_DIR}/cnf-certification-test/chaostesting \ # copy the rhcos_version_map - && cp -a \ - cnf-certification-test/chaostesting/chaos-test-files \ - ${TNF_DIR}/cnf-certification-test/chaostesting \ && mkdir -p ${TNF_DIR}/cnf-certification-test/platform/operatingsystem/files \ && cp \ cnf-certification-test/platform/operatingsystem/files/rhcos_version_map \ diff --git a/cnf-certification-test/chaostesting/chaos-test-files/chaos-engine.yaml b/cnf-certification-test/chaostesting/chaos-test-files/chaos-engine.yaml deleted file mode 100644 index bf87d8738..000000000 --- a/cnf-certification-test/chaostesting/chaos-test-files/chaos-engine.yaml +++ /dev/null @@ -1,24 +0,0 @@ -apiVersion: litmuschaos.io/v1alpha1 -kind: ChaosEngine -metadata: - name: engine-test - namespace: tnf -spec: - engineState: "active" - annotationCheck: "false" - appinfo: - appns: {{.APP_NAMESPACE}} - applabel: {{.APP_LABEL}} - appkind: {{.APP_KIND}} - chaosServiceAccount: test-sa - experiments: - - name: pod-delete - spec: - components: - env: - # provided as true for the force deletion of pod - # supports true and false value - - name: FORCE - value: 'true' - - name: TOTAL_CHAOS_DURATION - value: '60' diff --git a/cnf-certification-test/chaostesting/chaos-test-files/experiment-delete.yaml b/cnf-certification-test/chaostesting/chaos-test-files/experiment-delete.yaml deleted file mode 100644 index 22677112f..000000000 --- a/cnf-certification-test/chaostesting/chaos-test-files/experiment-delete.yaml +++ /dev/null @@ -1,104 +0,0 @@ -apiVersion: litmuschaos.io/v1alpha1 -description: - message: | - Deletes a pod belonging to a deployment/statefulset/daemonset -kind: ChaosExperiment -metadata: - name: pod-delete - namespace: {{.APP_NAMESPACE}} - labels: - name: pod-delete - app.kubernetes.io/part-of: litmus - app.kubernetes.io/component: chaosexperiment - app.kubernetes.io/version: 2.7.0 -spec: - definition: - scope: Namespaced - permissions: - # Create and monitor the experiment & helper pods - - apiGroups: [""] - resources: ["pods"] - verbs: ["create", "delete", "get", "list", "patch", "update", "deletecollection"] - # Performs CRUD operations on the events inside chaosengine and chaosresult - - apiGroups: [""] - resources: ["events"] - verbs: ["create", "get", "list", "patch", "update"] - # Fetch configmaps details and mount it to the experiment pod (if specified) - - apiGroups: [""] - resources: ["configmaps"] - verbs: ["get", "list", ] - # Track and get the runner, experiment, and helper pods log - - apiGroups: [""] - resources: ["pods/log"] - verbs: ["get", "list", "watch"] - # for creating and managing to execute commands inside target container - - apiGroups: [""] - resources: ["pods/exec"] - verbs: ["get", "list", "create"] - # deriving the parent/owner details of the pod(if parent is anyof {deployment, statefulset, daemonsets}) - - apiGroups: ["apps"] - resources: ["deployments", "statefulsets", "replicasets", "daemonsets"] - verbs: ["list", "get"] - # deriving the parent/owner details of the pod(if parent is deploymentConfig) - - apiGroups: ["apps.openshift.io"] - resources: ["deploymentconfigs"] - verbs: ["list", "get"] - # deriving the parent/owner details of the pod(if parent is deploymentConfig) - - apiGroups: [""] - resources: ["replicationcontrollers"] - verbs: ["get", "list"] - # deriving the parent/owner details of the pod(if parent is argo-rollouts) - - apiGroups: ["argoproj.io"] - resources: ["rollouts"] - verbs: ["list", "get"] - # for configuring and monitor the experiment job by the chaos-runner pod - - apiGroups: ["batch"] - resources: ["jobs"] - verbs: ["create", "list", "get", "delete", "deletecollection"] - # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow - - apiGroups: ["litmuschaos.io"] - resources: ["chaosengines", "chaosexperiments", "chaosresults"] - verbs: ["create", "list", "get", "patch", "update", "delete"] - image: "litmuschaos/go-runner:2.7.0" - imagePullPolicy: IfNotPresent - args: - - -c - - ./experiments -name pod-delete - command: - - /bin/bash - env: - - - name: TOTAL_CHAOS_DURATION - value: '15' - - # Period to wait before and after injection of chaos in sec - - name: RAMP_TIME - value: '' - - - name: FORCE - value: 'true' - - - name: CHAOS_INTERVAL - value: '5' - - ## percentage of total pods to target - - name: PODS_AFFECTED_PERC - value: '' - - - name: LIB - value: 'litmus' - - - name: TARGET_PODS - value: '' - - ## it defines the sequence of chaos execution for multiple target pods - ## supported values: serial, parallel - - name: SEQUENCE - value: 'parallel' - - labels: - name: pod-delete - namespace: {{.APP_NAMESPACE}} - app.kubernetes.io/part-of: litmus - app.kubernetes.io/component: experiment-job - app.kubernetes.io/version: 2.7.0 diff --git a/cnf-certification-test/chaostesting/chaos-test-files/service-account.yaml b/cnf-certification-test/chaostesting/chaos-test-files/service-account.yaml deleted file mode 100644 index b90ce7306..000000000 --- a/cnf-certification-test/chaostesting/chaos-test-files/service-account.yaml +++ /dev/null @@ -1,80 +0,0 @@ ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: test-sa - namespace: {{.APP_NAMESPACE}} - labels: - name: test-sa - app.kubernetes.io/part-of: litmus ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: test-sa - namespace: {{.APP_NAMESPACE}} - labels: - name: test-sa - app.kubernetes.io/part-of: litmus -rules: - # Create and monitor the experiment & helper pods - - apiGroups: [""] - resources: ["pods"] - verbs: ["create", "delete", "get", "list", "patch", "update", "deletecollection"] - # Performs CRUD operations on the events inside chaosengine and chaosresult - - apiGroups: [""] - resources: ["events"] - verbs: ["create", "get", "list", "patch", "update"] - # Fetch configmaps details and mount it to the experiment pod (if specified) - - apiGroups: [""] - resources: ["configmaps"] - verbs: ["get", "list", ] - # Track and get the runner, experiment, and helper pods log - - apiGroups: [""] - resources: ["pods/log"] - verbs: ["get", "list", "watch"] - # for creating and managing to execute commands inside target container - - apiGroups: [""] - resources: ["pods/exec"] - verbs: ["get", "list", "create"] - # deriving the parent/owner details of the pod(if parent is anyof {deployment, statefulset, daemonsets}) - - apiGroups: ["apps"] - resources: ["deployments", "statefulsets", "replicasets", "daemonsets"] - verbs: ["list", "get"] - # deriving the parent/owner details of the pod(if parent is deploymentConfig) - - apiGroups: ["apps.openshift.io"] - resources: ["deploymentconfigs"] - verbs: ["list", "get"] - # deriving the parent/owner details of the pod(if parent is deploymentConfig) - - apiGroups: [""] - resources: ["replicationcontrollers"] - verbs: ["get", "list"] - # deriving the parent/owner details of the pod(if parent is argo-rollouts) - - apiGroups: ["argoproj.io"] - resources: ["rollouts"] - verbs: ["list", "get"] - # for configuring and monitor the experiment job by the chaos-runner pod - - apiGroups: ["batch"] - resources: ["jobs"] - verbs: ["create", "list", "get", "delete", "deletecollection"] - # for creation, status polling and deletion of litmus chaos resources used within a chaos workflow - - apiGroups: ["litmuschaos.io"] - resources: ["chaosengines", "chaosexperiments", "chaosresults"] - verbs: ["create", "list", "get", "patch", "update", "delete"] ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: test-sa - namespace: {{.APP_NAMESPACE}} - labels: - name: test-sa -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: test-sa -subjects: - - kind: ServiceAccount - name: test-sa - namespace: {{.APP_NAMESPACE}} - diff --git a/cnf-certification-test/chaostesting/pod_delete/pod_delete.go b/cnf-certification-test/chaostesting/pod_delete/pod_delete.go deleted file mode 100644 index 2cd87ac33..000000000 --- a/cnf-certification-test/chaostesting/pod_delete/pod_delete.go +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (C) 2020-2023 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -package poddelete - -/* - -import ( - "bufio" - "bytes" - "context" - "errors" - "fmt" - "io" - "text/template" - "time" - - "github.com/test-network-function/cnf-certification-test/pkg/provider" - "github.com/test-network-function/cnf-certification-test/pkg/tnf" - - "github.com/test-network-function/cnf-certification-test/internal/clientsholder" - "github.com/test-network-function/cnf-certification-test/internal/log" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer/yaml" - yamlutil "k8s.io/apimachinery/pkg/util/yaml" - "k8s.io/client-go/restmapper" - - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic" -) - -const ( - // custom resources file to create them - serviceAccountFile = "chaostesting/chaos-test-files/service-account.yaml" - experimentFile = "chaostesting/chaos-test-files/experiment-delete.yaml" - chaosEngineFile = "chaostesting/chaos-test-files/chaos-engine.yaml" - chaosTestName = "pod-delete" // test name - completedResult = "completed" - pass = "Pass" - chaosresultName = "engine-test-pod-delete" -) - -// GetLabelDeploymentValue a function to search the right label for the deployment that we want to test pod delete on it -func GetLabelDeploymentValue(env *provider.TestEnvironment, labelsMap map[string]string) (string, error) { - var key string - for _, label := range env.Config.TargetPodLabels { - if label.Prefix != "" { - key = fmt.Sprintf("%s/%s", label.Prefix, label.Name) - } else { - key = label.Name - } - if l, ok := labelsMap[key]; ok && l == label.Value { - return fmt.Sprintf("%s=%s", key, label.Value), nil - } - } - return "", errors.New("did not find a key and value that matching the deployment") -} - -// ApplyAndCreatePodDeleteResources creates resources necessary for the chaos testing -func ApplyAndCreatePodDeleteResources(appLabel, appKind, namespace string) error { - // create the chaos experiment resource - if err := applyAndCreateFile(appLabel, appKind, namespace, experimentFile); err != nil { - log.Error("cant create the experiment of the test: %s", err) - return err - } - // create the chaos serviceAccount resource - if err := applyAndCreateFile(appLabel, appKind, namespace, serviceAccountFile); err != nil { - log.Error("cant create the serviceAccount of the test: %s", err) - return err - } - // create the chaos chaosEngine resource - if err := applyAndCreateFile(appLabel, appKind, namespace, chaosEngineFile); err != nil { - log.Error("cant create the chaosEngine of the test: %s", err) - return err - } - return nil -} - -func applyAndCreateFile(appLabel, appKind, namespace, filename string) error { - fileDecoder, err := applyTemplate(appLabel, appKind, namespace, filename) - if err != nil { - log.Error("cant create the decoderfile of the test: %s", err) - return err - } - if err = createResource(fileDecoder); err != nil { - log.Error("%s error create the resources for the test.", err) - return err - } - return nil -} - -// DeleteAllResources deletes all chaostesting resources -func DeleteAllResources(namespace string) { - oc := clientsholder.GetClientsHolder() - deletePolicy := metav1.DeletePropagationForeground - deleteOptions := metav1.DeleteOptions{ - PropagationPolicy: &deletePolicy, - } - gvr := schema.GroupVersionResource{Group: "litmuschaos.io", Version: "v1alpha1", Resource: "chaosengines"} - if err := oc.DynamicClient.Resource(gvr).Namespace(namespace).Delete(context.TODO(), "engine-test", deleteOptions); err != nil { - log.Error("error while removing the chaos engine resources %s", err) - } - err := oc.K8sClient.CoreV1().ServiceAccounts(namespace).Delete(context.TODO(), "test-sa", deleteOptions) - if err != nil { - log.Error("error while removing the ServiceAccounts resources %s", err) - } - if err = oc.K8sClient.RbacV1().Roles(namespace).Delete(context.TODO(), "test-sa", deleteOptions); err != nil { - log.Error("error while removing the chaos engine resources %s", err) - } - if err = oc.K8sClient.RbacV1().RoleBindings(namespace).Delete(context.TODO(), "test-sa", deleteOptions); err != nil { - log.Error("error while removing the chaos engine resources %s", err) - } - gvr = schema.GroupVersionResource{Group: "litmuschaos.io", Version: "v1alpha1", Resource: "chaosexperiments"} - if err := oc.DynamicClient.Resource(gvr).Namespace(namespace).Delete(context.TODO(), chaosTestName, deleteOptions); err != nil { - log.Error("error while removing the chaos engine resources %s", err) - } - gvr = schema.GroupVersionResource{Group: "litmuschaos.io", Version: "v1alpha1", Resource: "chaosresults"} - if err := oc.DynamicClient.Resource(gvr).Namespace(namespace).Delete(context.TODO(), chaosresultName, deleteOptions); err != nil { - log.Error("error while removing the chaos results resources %s", err) - } -} - -func applyTemplate(appLabel, appKind, namespace, filename string) (*yamlutil.YAMLOrJSONDecoder, error) { - // variables - vars := make(map[string]interface{}) - vars["APP_NAMESPACE"] = namespace - vars["APP_LABEL"] = appLabel - vars["APP_KIND"] = appKind - output, err := fillTemplate(filename, vars) - if err != nil { - log.Error("error while executing the template to the yaml file %s", err) - return nil, err - } - const oneh = 100 - fileDecoder := yamlutil.NewYAMLOrJSONDecoder(bytes.NewReader(output), oneh) - return fileDecoder, nil -} - -func fillTemplate(file string, values map[string]interface{}) ([]byte, error) { - // parse the template - tmpl, err := template.ParseFiles(file) - if err != nil { - log.Error("error while parsing the yaml file: %s error: %v", file, err) - return nil, err - } - var buffer bytes.Buffer - writer := bufio.NewWriter(&buffer) - if err := tmpl.Execute(writer, values); err != nil { - log.Error("error while executing the template to the yaml file: %s error: %v", file, err) - return nil, err - } - writer.Flush() // write to the buffer - return buffer.Bytes(), nil -} - -// WaitForTestFinish waits for the tests to finish -func WaitForTestFinish(timeout time.Duration) bool { - const pollingPeriod = 1 * time.Second - var elapsed time.Duration - var result bool - for elapsed < timeout { - result = waitForResult() - - if result { - break - } - time.Sleep(pollingPeriod) - elapsed += pollingPeriod - } - return result -} - -// IsChaosResultVerdictPass determine the pass/fail result -func IsChaosResultVerdictPass() bool { - oc := clientsholder.GetClientsHolder() - gvr := schema.GroupVersionResource{Group: "litmuschaos.io", Version: "v1alpha1", Resource: "chaosresults"} - crs, err := oc.DynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{}) - if err != nil { - log.Error("error getting : %v\n", err) - return false - } - if len(crs.Items) > 1 { - log.Error("There are currently %d chaosresults resources. That is incorrect behavior.\n", len(crs.Items)) - return false - } - cr := crs.Items[0] - failResult := cr.Object["status"].(map[string]interface{})["experimentStatus"].(map[string]interface{})["failStep"] - verdictValue := cr.Object["status"].(map[string]interface{})["experimentStatus"].(map[string]interface{})["verdict"] - expKind := cr.Object["spec"].(map[string]interface{})["experiment"] - if expKind == chaosTestName { - if verdictValue == pass { - return true - } - log.Warn("test completed but it failed with reason %s", failResult.(string)) - return false - } - return false -} - -func waitForResult() bool { - oc := clientsholder.GetClientsHolder() - gvr := schema.GroupVersionResource{Group: "litmuschaos.io", Version: "v1alpha1", Resource: "chaosengines"} - crs, err := oc.DynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{}) - if err != nil { - log.Error("error getting : %v\n", err) - return false - } - - return parseLitmusResult(crs) -} - -func parseLitmusResult(crs *unstructured.UnstructuredList) bool { - if len(crs.Items) > 1 { - log.Error("There are currently %d chaosengine resources. That is incorrect behavior.\n", len(crs.Items)) - return false - } - cr := crs.Items[0] - if status := cr.Object["status"]; status != nil { - if exp := status.(map[string]interface{})["experiments"]; exp != nil { - typ := exp.([]interface{}) - engineStatus := cr.Object["status"].(map[string]interface{})["engineStatus"] - if typ[0].(map[string]interface{})["name"] == chaosTestName { - return engineStatus == completedResult - } - } - } - return false -} - -// createResource is a helper function that uses a yaml decoder to create in the cluster -// all the resources defined in the underlying yaml file. -func createResource(decoder *yamlutil.YAMLOrJSONDecoder) error { - oc := clientsholder.GetClientsHolder() - k8sClient := oc.K8sClient - dynamicClient := oc.DynamicClient - for { - var rawObj runtime.RawExtension - if err := decoder.Decode(&rawObj); err != nil { - if err != io.EOF { - return err - } - return nil - } - obj, gvk, err := yaml.NewDecodingSerializer(unstructured.UnstructuredJSONScheme).Decode(rawObj.Raw, nil, nil) - if err != nil { - return err - } - unstructuredMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) - if err != nil { - return err - } - - unstructuredObj := &unstructured.Unstructured{Object: unstructuredMap} - - gr, err := restmapper.GetAPIGroupResources(k8sClient.Discovery()) - if err != nil { - return err - } - - mapper := restmapper.NewDiscoveryRESTMapper(gr) - mapping, err := mapper.RESTMapping(gvk.GroupKind(), gvk.Version) - if err != nil { - return err - } - - var dri dynamic.ResourceInterface - if mapping.Scope.Name() == meta.RESTScopeNameNamespace { - if unstructuredObj.GetNamespace() == "" { - unstructuredObj.SetNamespace("default") - } - dri = dynamicClient.Resource(mapping.Resource).Namespace(unstructuredObj.GetNamespace()) - } else { - dri = dynamicClient.Resource(mapping.Resource) - } - - if _, err := dri.Create(context.TODO(), unstructuredObj, metav1.CreateOptions{}); err != nil { - return err - } - } -} - -*/ diff --git a/cnf-certification-test/chaostesting/pod_delete/pod_delete_test.go b/cnf-certification-test/chaostesting/pod_delete/pod_delete_test.go deleted file mode 100644 index d9d3684bc..000000000 --- a/cnf-certification-test/chaostesting/pod_delete/pod_delete_test.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2020-2023 Red Hat, Inc. -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -package poddelete - -/* - -import ( - "errors" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/test-network-function/cnf-certification-test/pkg/configuration" - "github.com/test-network-function/cnf-certification-test/pkg/provider" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -func TestGetLabelDeploymentValue(t *testing.T) { - generateEnv := func(name, prefix, value string) *provider.TestEnvironment { - return &provider.TestEnvironment{ - Config: configuration.TestConfiguration{ - TargetPodLabels: []configuration.Label{ - { - Name: name, - Prefix: prefix, - Value: value, - }, - }, - }, - } - } - - testCases := []struct { - testName string - testPrefix string - testValue string - testMap map[string]string - expectedOutput string - expectedErr error - }{ - { // Test Case #1 - Happy path - testName: "test1", - testPrefix: "prefix1", - testValue: "value1", - testMap: map[string]string{ - "prefix1/test1": "value1", - }, - expectedOutput: "prefix1/test1=value1", - }, - { // Test Case #2 - Missing map value - testName: "test1", - testPrefix: "prefix1", - testValue: "value1", - testMap: map[string]string{}, - expectedOutput: "", - expectedErr: errors.New("did not find a key and value that matching the deployment"), - }, - { // Test Case #3 - Happy path, no prefix - testName: "test1", - testPrefix: "", - testValue: "value1", - testMap: map[string]string{ - "test1": "value1", - }, - expectedOutput: "test1=value1", - }, - } - - for _, tc := range testCases { - result, err := GetLabelDeploymentValue(generateEnv(tc.testName, tc.testPrefix, tc.testValue), tc.testMap) - assert.Equal(t, tc.expectedErr, err) - assert.Equal(t, tc.expectedOutput, result) - } -} - -func TestParseLitmusResult(t *testing.T) { - testCases := []struct { - testList *unstructured.UnstructuredList - expectedOutput bool - }{ - { // Test Case #1 - Two objects, return false - testList: &unstructured.UnstructuredList{ - Items: []unstructured.Unstructured{ - { - Object: map[string]interface{}{}, - }, - { - Object: map[string]interface{}{}, - }, - }, - }, - expectedOutput: false, - }, - { // Test Case 2 - status not set, return false - testList: &unstructured.UnstructuredList{ - Items: []unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "wrongKeyName": nil, - }, - }, - }, - }, - expectedOutput: false, - }, - { // Test Case 3 - "experiments" set nil, return false - testList: &unstructured.UnstructuredList{ - Items: []unstructured.Unstructured{ - { - Object: map[string]interface{}{ - "status": map[string]interface{}{ - "experiments": nil, - }, - }, - }, - }, - }, - expectedOutput: false, - }, - // TODO: Add more tests here parsing the []interfaces. - } - - for _, tc := range testCases { - assert.Equal(t, tc.expectedOutput, parseLitmusResult(tc.testList)) - } -} - -*/ diff --git a/cnf-certification-test/chaostesting/suite.go b/cnf-certification-test/chaostesting/suite.go deleted file mode 100644 index 8a3b42d40..000000000 --- a/cnf-certification-test/chaostesting/suite.go +++ /dev/null @@ -1,77 +0,0 @@ -package chaostesting - -/* - -import ( - "fmt" - "time" - - "github.com/test-network-function/cnf-certification-test/pkg/provider" - - - poddelete "github.com/test-network-function/cnf-certification-test/cnf-certification-test/chaostesting/pod_delete" - "github.com/test-network-function/cnf-certification-test/cnf-certification-test/identifiers" - "github.com/test-network-function/cnf-certification-test/internal/log" - - "github.com/onsi/ginkgo/v2" - "github.com/test-network-function/cnf-certification-test/cnf-certification-test/common" - "github.com/test-network-function/cnf-certification-test/cnf-certification-test/results" -) - -const ( - // timeout for eventually call - testCaseTimeout = 180 * time.Second - deployment = "deployment" -) - -var _ = ginkgo.Describe(common.ChaosTesting, func() { - log.Debug("Entering %s suite", common.ChaosTesting) - var env provider.TestEnvironment - - ginkgo.BeforeEach(func() { - env = provider.GetTestEnvironment() - }) - ginkgo.ReportAfterEach(results.RecordResult) - ginkgo.AfterEach(func() { - // Note: Reloading test environment here because it is possible - // that some of the resources that are gathered prior to the chaos test - // have been deleted and need another record created. - env.SetNeedsRefresh() - }) - - testID, tags := identifiers.GetGinkgoTestIDAndLabels(identifiers.TestPodDeleteIdentifier) - ginkgo.It(testID, ginkgo.Label(tags...), func() { - testPodDelete(&env) - }) - -}) - -func testPodDelete(env *provider.TestEnvironment) { - ginkgo.Skip("This TC is under construction.") - - for _, dep := range env.Deployments { - var label string - var err error - if label, err = poddelete.GetLabelDeploymentValue(env, dep.Spec.Template.Labels); err != nil { - log.Error("did not find a match label for the deployment %s ", dep.ToString()) - ginkgo.Fail(fmt.Sprintf("There is no label for the deployment %s ", dep.ToString())) - } - if err := poddelete.ApplyAndCreatePodDeleteResources(label, deployment, dep.Namespace); err != nil { - ginkgo.Fail(fmt.Sprintf("test failed while creating the resources err:%s", err)) - } - if completed := poddelete.WaitForTestFinish(testCaseTimeout); !completed { - poddelete.DeleteAllResources(dep.Namespace) - log.Error("deployment %s timed-out the litmus test", dep.ToString()) - ginkgo.Fail(fmt.Sprintf("deployment %s timed-out the litmus test", dep.ToString())) - } - if result := poddelete.IsChaosResultVerdictPass(); !result { - // delete the chaos engin crd - poddelete.DeleteAllResources(dep.Namespace) - log.Error("deployment %s failed the litmus test", dep.ToString()) - ginkgo.Fail(fmt.Sprintf("deployment %s failed the litmus test", dep.ToString())) - } - poddelete.DeleteAllResources(dep.Namespace) - } -} - -*/ diff --git a/cnf-certification-test/chaostesting/suite_test.go b/cnf-certification-test/chaostesting/suite_test.go deleted file mode 100644 index aa5d1140f..000000000 --- a/cnf-certification-test/chaostesting/suite_test.go +++ /dev/null @@ -1 +0,0 @@ -package chaostesting diff --git a/cnf-certification-test/common/constant.go b/cnf-certification-test/common/constant.go index 1b65e57dc..dfb44c8aa 100644 --- a/cnf-certification-test/common/constant.go +++ b/cnf-certification-test/common/constant.go @@ -18,11 +18,10 @@ package common // Constants shared by multiple test suite packages const ( - defaultTimeoutSeconds = 10 - AccessControlTestKey = "access-control" - LifecycleTestKey = "lifecycle" - ManageabilityTestKey = "manageability" - // ChaosTesting = "chaostesting" + defaultTimeoutSeconds = 10 + AccessControlTestKey = "access-control" + LifecycleTestKey = "lifecycle" + ManageabilityTestKey = "manageability" AffiliatedCertTestKey = "affiliated-certification" NetworkingTestKey = "networking" ObservabilityTestKey = "observability"