Skip to content

Commit

Permalink
CI: Generate e2e artifacts and upload
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquim Moreno Prusi <joaquim@redhat.com>
  • Loading branch information
jmprusi committed Jul 19, 2023
1 parent afdf5b9 commit ffbc1eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ jobs:

- name: Run e2e tests
run: |
make e2e
ARTIFACT_PATH=/tmp/artifacts make e2e
- uses: cytopia/upload-artifact-retry-action@v0.1.7
if: failure()
with:
name: e2e-artifacts
path: /tmp/artifacts/
31 changes: 15 additions & 16 deletions test/e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import (
"os"
"path/filepath"
"strings"
"time"

operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
operatorv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
"gopkg.in/yaml.v2"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -28,13 +27,13 @@ import (

catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
)

const (
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
testCatalogName = "test-catalog"
artifactName = "operator-controller-e2e"
defaultTimeout = 30 * time.Second
defaultPoll = 1 * time.Second
testCatalogRef = "localhost/testdata/catalogs/test-catalog:e2e"
artifactName = "operator-controller-e2e"
)

var _ = Describe("Operator Install", func() {
Expand Down Expand Up @@ -240,7 +239,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal operator %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, operator.Name+"-operator.yaml"), operatorYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write operator to file %w", err)
}
}
Expand All @@ -257,7 +256,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal catalogsource %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, catalogsource.Name+"-catalogsource.yaml"), catalogsourceYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write catalogsource to file %w", err)
}
}
Expand All @@ -274,7 +273,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal bundle %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, bundle.Name+"-bundle.yaml"), bundleYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write bundle to file %w", err)
}
}
Expand All @@ -291,7 +290,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal bundleDeployment %w", err)
continue
}
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(artifactPath, bundleDeployment.Name+"-bundleDeployment.yaml"), bundleDeploymentYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write bundleDeployment to file %w", err)
}
}
Expand Down Expand Up @@ -322,7 +321,7 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to marshal deployment %w", err)
continue
}
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0644); err != nil {
if err := os.WriteFile(filepath.Join(namespacedArtifactPath, deployment.Name+"-deployment.yaml"), deploymentYaml, 0600); err != nil {
GinkgoWriter.Printf("Failed to write deployment to file %w", err)
}
}
Expand All @@ -333,11 +332,11 @@ func getArtifactsOutput(ctx context.Context, basePath string) {
GinkgoWriter.Printf("Failed to list pods %w in namespace: %q", err, namespace.Name)
}
for _, pod := range pods.Items {
if pod.Status.Phase != v1.PodRunning && pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
if pod.Status.Phase != corev1.PodRunning && pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {
continue
}
for _, container := range pod.Spec.Containers {
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &v1.PodLogOptions{Container: container.Name}).Stream(ctx)
logs, err := kubeClient.CoreV1().Pods(namespace.Name).GetLogs(pod.Name, &corev1.PodLogOptions{Container: container.Name}).Stream(ctx)
if err != nil {
GinkgoWriter.Printf("Failed to get logs for pod %q in namespace %q: %w", pod.Name, namespace.Name, err)
continue
Expand Down

0 comments on commit ffbc1eb

Please sign in to comment.