Skip to content

Commit

Permalink
Merge branch 'main' into issue/783
Browse files Browse the repository at this point in the history
  • Loading branch information
garloff authored Oct 16, 2024
2 parents d97113c + e2922ed commit 2c43a7a
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 94 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/lint-golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Go syntax

on:
push:
paths:
- 'Tests/kaas/kaas-sonobuoy-tests/**/*.go'
- .github/workflows/lint-go.yml

jobs:
lint-go-syntax:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

# Install golangci-lint
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
# Run golangci-lint
- name: Run golangci-lint
working-directory: Tests/kaas/kaas-sonobuoy-tests
run: golangci-lint run ./... -v
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
<!-- markdownlint-disable -->
# Sovereign Cloud Stack – Standards and Certification

SCS unifies the best of cloud computing in a certified standard. With a decentralized and federated cloud stack, SCS puts users in control of their data and fosters trust in clouds, backed by a global open-source community.

## SCS compatible clouds

This is a list of clouds that we test on a nightly basis against our `scs-compatible` certification level.

| Name | Description | Operator | _SCS-compatible IaaS_ Compliance | HealthMon |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ----------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------: |
| [gx-scs](https://github.com/SovereignCloudStack/docs/blob/main/community/cloud-resources/plusserver-gx-scs.md) | Dev environment provided for SCS & GAIA-X context | plusserver GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-gx-scs-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-gx-scs-v4.yml) | [HM](https://health.gx-scs.sovereignit.cloud:3000/) |
| [pluscloud open](https://www.plusserver.com/en/products/pluscloud-open)<br />- prod1<br />- prod2<br />- prod3<br />- prod4 | Public cloud for customers (4 regions) | plusserver GmbH | &nbsp;<br />- prod1 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-pco-prod1-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-pco-prod1-v4.yml)<br />- prod2 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-pco-prod2-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-pco-prod2-v4.yml)<br />- prod3 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-pco-prod3-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-pco-prod3-v4.yml)<br />- prod4 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-pco-prod4-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-pco-prod4-v4.yml) | &nbsp;<br />[HM1](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-pco)<br />[HM2](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod2)<br />[HM3](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod3)<br />[HM4](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod4) |
| [Wavestack](https://www.noris.de/wavestack-cloud/) | Public cloud for customers | noris network AG/Wavecon GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-wavestack-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-wavestack-v4.yml) | [HM](https://health.wavestack1.sovereignit.cloud:3000/) |
| [REGIO.cloud](https://regio.digital) | Public cloud for customers | OSISM GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-regio-a-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-regio-a-v4.yml) | broken <!--[HM](https://apimon.services.regio.digital/public-dashboards/17cf094a47404398a5b8e35a4a3968d4?orgId=1&refresh=5m)--> |
| [CNDS](https://cnds.io/) | Public cloud for customers | artcodix GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-artcodix-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-artcodix-v4.yml) | [HM](https://ohm.muc.cloud.cnds.io/) |
| [aov.cloud](https://www.aov.de/) | Community cloud for customers | aov IT.Services GmbH | (soon) | [HM](https://health.aov.cloud/) |
| PoC WG-Cloud OSBA | Cloud PoC for FITKO (yaook-based) | Cloud&amp;Heat Technologies GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-poc-wgcloud-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-poc-wgcloud-v4.yml) | [HM](https://health.poc-wgcloud.osba.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?var-mycloud=poc-wgcloud&orgId=1) |
| PoC KDO | Cloud PoC for FITKO | KDO Service GmbH / OSISM GmbH | [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-poc-kdo-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-poc-kdo-v4.yml) | (soon) |
| [syseleven](https://www.syseleven.de/en/products-services/openstack-cloud/)<br />- dus2<br />- ham1 | Public OpenStack Cloud (2 SCS regions) | SysEleven GmbH | &nbsp;<br />- dus2 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-syseleven-dus2-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-syseleven-dus2-v4.yml)<br />- ham1 [![Compliance Status](https://img.shields.io/github/actions/workflow/status/SovereignCloudStack/standards/check-syseleven-ham1-v4.yml?label=v4)](https://github.com/SovereignCloudStack/standards/actions/workflows/check-syseleven-ham1-v4.yml) | &nbsp;<br />(soon)<br />(soon) |
See [Compliant clouds overview](https://docs.scs.community/standards/certification/overview) on our docs page.

## SCS standards overview

Expand Down
17 changes: 13 additions & 4 deletions Tests/kaas/kaas-sonobuoy-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ test-function:
@echo "only run tests for: $${TESTFUNCTION_CODE}"
DEVELOPMENT_MODE=createcluster go test -run=$${TESTFUNCTION_CODE} ./... || true


lint:
@echo "NOT YET IMPLEMENTED"

lint: check-golangci-lint
@echo "[Running golangci-lint...]"
@golangci-lint run ./... -v || true

GOLANGCI_LINT_VERSION ?= v1.61.0
check-golangci-lint:
@if ! [ -x "$$(command -v golangci-lint)" ]; then \
echo "[golangci-lint not found, installing...]"; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \
echo "[golangci-lint installed]"; \
else \
echo "[golangci-lint is already installed]"; \
fi

dev-clean-result:
@rm -rf *.tar.gz || true
Expand Down
146 changes: 76 additions & 70 deletions Tests/kaas/kaas-sonobuoy-tests/scs_k8s_conformance_tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ package scs_k8s_tests
import (
"context"
"fmt"
"log"
"os"
"testing"
"log"

plugin_helper "github.com/vmware-tanzu/sonobuoy-plugins/plugin-helper"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/e2e-framework/pkg/env"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/envfuncs"
)

// Define a custom type for the context key
type nsContextKey string

// Define a custom type for context keys
type contextKey string

const (
ProgressReporterCtxKey = "SONOBUOY_PROGRESS_REPORTER"
NamespacePrefixKey = "NS_PREFIX"
DevelopmentModeKey = "DEVELOPMENT_MODE"
NamespacePrefixKey = "NS_PREFIX"
DevelopmentModeKey = "DEVELOPMENT_MODE"
)

var testenv env.Environment
Expand All @@ -33,82 +39,82 @@ func TestMain(m *testing.M) {
updateReporter := plugin_helper.NewProgressReporter(0)

developmentMode := os.Getenv(DevelopmentModeKey)
log.Printf("Setup test enviornment for: %#v", developmentMode )

switch KubernetesEnviornment := developmentMode; KubernetesEnviornment {

case "createcluster":
log.Println("Create kind cluster for test")
testenv = env.New()
kindClusterName := envconf.RandomName("gotestcluster", 16)
//~ namespace := envconf.RandomName("testnamespace", 16)

testenv.Setup(
envfuncs.CreateKindCluster(kindClusterName),
)

testenv.Finish(
//~ envfuncs.DeleteNamespace(namespace),
envfuncs.DestroyKindCluster(kindClusterName),
)

case "usecluster":
log.Println("Use existing k8s cluster for the test")
log.Println("Not Yet Implemented")
//~ testenv = env.NewFromFlags()
//~ KubeConfig:= os.Getenv(KUBECONFIGFILE)
//~ testenv = env.NewWithKubeConfig(KubeConfig)

default:
// Assume we are running in the cluster as a Sonobuoy plugin.
log.Println("Running tests inside k8s cluster")
testenv = env.NewInClusterConfig()

testenv.Setup(func(ctx context.Context, config *envconf.Config) (context.Context, error) {
// Try and create the client; doing it before all the tests allows the tests to assume
// it can be created without error and they can just use config.Client().
_,err:=config.NewClient()
return context.WithValue(ctx,ProgressReporterCtxKey,updateReporter) ,err
})

testenv.Finish(
func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
log.Println("Finished go test suite")
//~ if err := ???; err != nil{
//~ return ctx, err
//~ }
return ctx, nil
},
)

}
log.Printf("Setup test enviornment for: %#v", developmentMode)

switch KubernetesEnviornment := developmentMode; KubernetesEnviornment {

case "createcluster":
log.Println("Create kind cluster for test")
testenv = env.New()
kindClusterName := envconf.RandomName("gotestcluster", 16)
//~ namespace := envconf.RandomName("testnamespace", 16)

testenv.Setup(
envfuncs.CreateKindCluster(kindClusterName),
)

testenv.Finish(
//~ envfuncs.DeleteNamespace(namespace),
envfuncs.DestroyKindCluster(kindClusterName),
)

case "usecluster":
log.Println("Use existing k8s cluster for the test")
log.Println("Not Yet Implemented")
//~ testenv = env.NewFromFlags()
//~ KubeConfig:= os.Getenv(KUBECONFIGFILE)
//~ testenv = env.NewWithKubeConfig(KubeConfig)

default:
// Assume we are running in the cluster as a Sonobuoy plugin.
log.Println("Running tests inside k8s cluster")
testenv = env.NewInClusterConfig()

testenv.Setup(func(ctx context.Context, config *envconf.Config) (context.Context, error) {
// Try and create the client; doing it before all the tests allows the tests to assume
// it can be created without error and they can just use config.Client().
_, err := config.NewClient()
return context.WithValue(ctx, contextKey(ProgressReporterCtxKey), updateReporter), err
})

testenv.Finish(
func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
log.Println("Finished go test suite")
//~ if err := ???; err != nil{
//~ return ctx, err
//~ }
return ctx, nil
},
)

}

testenv.BeforeEachTest(func(ctx context.Context, cfg *envconf.Config, t *testing.T) (context.Context, error) {
fmt.Println("BeforeEachTest")
fmt.Println("BeforeEachTest")
updateReporter.StartTest(t.Name())
return createNSForTest(ctx, cfg, t, runID)
})

testenv.AfterEachTest(func(ctx context.Context, cfg *envconf.Config, t *testing.T) (context.Context, error) {
fmt.Println("AfterEachTest")
updateReporter.StopTest(t.Name(),t.Failed(),t.Skipped(),nil)
fmt.Println("AfterEachTest")
updateReporter.StopTest(t.Name(), t.Failed(), t.Skipped(), nil)
return deleteNSForTest(ctx, cfg, t, runID)
})

/*
testenv.BeforeEachFeature(func(ctx context.Context, config *envconf.Config, info features.Feature) (context.Context, error) {
// Note that you can also add logic here for before a feature is tested. There may be
// more than one feature in a test.
fmt.Println("BeforeEachFeature")
return ctx, nil
})
testenv.AfterEachFeature(func(ctx context.Context, config *envconf.Config, info features.Feature) (context.Context, error) {
// Note that you can also add logic here for after a feature is tested. There may be
// more than one feature in a test.
fmt.Println("AfterEachFeature")
return ctx, nil
})
testenv.BeforeEachFeature(func(ctx context.Context, config *envconf.Config, info features.Feature) (context.Context, error) {
// Note that you can also add logic here for before a feature is tested. There may be
// more than one feature in a test.
fmt.Println("BeforeEachFeature")
return ctx, nil
})
testenv.AfterEachFeature(func(ctx context.Context, config *envconf.Config, info features.Feature) (context.Context, error) {
// Note that you can also add logic here for after a feature is tested. There may be
// more than one feature in a test.
fmt.Println("AfterEachFeature")
return ctx, nil
})
*/

os.Exit(testenv.Run(m))
Expand Down Expand Up @@ -136,6 +142,6 @@ func deleteNSForTest(ctx context.Context, cfg *envconf.Config, t *testing.T, run
return ctx, cfg.Client().Resources().Delete(ctx, &nsObj)
}

func nsKey(t *testing.T) string {
return "NS-for-%v" + t.Name()
func nsKey(t *testing.T) nsContextKey {
return nsContextKey("NS-for-" + t.Name())
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package scs_k8s_tests

import (
"os"
"testing"
"os"
)


func Test_scs_0200_smoke(t *testing.T) {
// This test ensures that no DevelopmentMode was set
// when using this test-suite productively
developmentMode := os.Getenv(DevelopmentModeKey)
// This test ensures that no DevelopmentMode was set
// when using this test-suite productively
developmentMode := os.Getenv(DevelopmentModeKey)
if developmentMode != "" {
t.Errorf("developmentMode is set to = %v; want None", developmentMode )
t.Errorf("developmentMode is set to = %v; want None", developmentMode)
}
}

0 comments on commit 2c43a7a

Please sign in to comment.