Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: suite

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
ContainerRegistry: "ghcr.io"
ContainerRegistryRepo: "ghcr.io/eclipse-symphony"

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: Set up custom GOPATH
run: |
mkdir -p /home/runner/go
echo "export GOPATH=/home/runner/go" >> $HOME/.bashrc
echo "export PATH=\$PATH:\$GOPATH/bin" >> $HOME/.bashrc
source $HOME/.bashrc

- name: Install make
run: sudo apt-get update && sudo apt-get install -y build-essential

- name: Check docker version and images
run: docker --version && docker images

- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client
kubectl config view

- name: Install Helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

- name: Install minikube
run: |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/
minikube start
kubectl config view

- name: Install Mage
run: |
cd ..
git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go
cd ..

- name: Install Ginkgo
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.13.1
export PATH=$PATH:$(go env GOPATH)/bin

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.ContainerRegistry }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build docker images
run: |
cd test/localenv/
mage build:all
mage cluster:up

- name: Go work init
run: |
mv go.work.bk go.work

- name: Run ginkgo suite tests
run: |
cd test/integration/scenarios/06.ado/
ginkgo --cover --junit-report=junit-suite-tests.xml -r
continue-on-error: true

- name: Dump SymphonyLogs For ginkgo suite tests
run: |
cd test/localenv/
mage DumpSymphonyLogsForTest ginkgosuite
continue-on-error: true

- name: Collect and upload symphony test results
uses: actions/upload-artifact@v2
with:
name: symphony-suite-result
path: |
test/integration/scenarios/06.ado/junit-suite-tests.xml
/tmp/symhony-integration-test-logs/**/*.log
continue-on-error: true
if: always()
2 changes: 0 additions & 2 deletions agent/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ pub struct StagedProperties {
}
#[derive(Serialize, Deserialize)]
pub struct CatalogSpec {
#[serde(rename = "siteId")]
site_id: String,
#[serde(rename = "type")]
pub catalog_type: String,
pub properties: StagedProperties,
Expand Down
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ EXPOSE 8080
EXPOSE 8081
ENV LOG_LEVEL Debug
# ENV CONFIG /symphony-api.json
CMD exec /symphony-api -c $CONFIG -l $LOG_LEVEL
CMD sh -c 'if [ -f /etc/pki/ca-trust/source/anchors/proxy-cert.crt ]; then update-ca-trust; fi && exec /symphony-api -c $CONFIG -l $LOG_LEVEL'
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var catalogState = model.CatalogState{
Name: "name1",
},
Spec: &model.CatalogSpec{
SiteId: "site1",
Type: "catalog",
Type: "catalog",
Properties: map[string]interface{}{
"property1": "value1",
"property2": "value2",
Expand Down
80 changes: 70 additions & 10 deletions api/pkg/apis/v1alpha1/managers/solutions/solutions-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/eclipse-symphony/symphony/api/pkg/apis/v1alpha1/model"
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2"
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/contexts"
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/managers"
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/providers"
"github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/providers/states"
"github.com/eclipse-symphony/symphony/coa/pkg/logger"

observability "github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/observability"
observ_utils "github.com/eclipse-symphony/symphony/coa/pkg/apis/v1alpha2/observability/utils"
)

var sLog = logger.NewLogger("coa.runtime")

type SolutionsManager struct {
managers.Manager
StateProvider states.IStateProvider
Expand All @@ -48,14 +52,26 @@ func (t *SolutionsManager) DeleteState(ctx context.Context, name string, namespa
var err error = nil
defer observ_utils.CloseSpanWithError(span, &err)

var rootResource string
var version string
parts := strings.Split(name, ":")
if len(parts) == 2 {
rootResource = parts[0]
version = parts[1]
} else {
return v1alpha2.NewCOAError(nil, fmt.Sprintf("Name is invalid does not match name in request (%s)", name), v1alpha2.BadRequest)
}

id := rootResource + "-" + version
err = t.StateProvider.Delete(ctx, states.DeleteRequest{
ID: name,
ID: id,
Metadata: map[string]interface{}{
"namespace": namespace,
"group": model.SolutionGroup,
"version": "v1",
"resource": "solutions",
"kind": "Solution",
"namespace": namespace,
"group": model.SolutionGroup,
"version": "v1",
"resource": "solutions",
"kind": "Solution",
"rootResource": rootResource,
},
})
return err
Expand All @@ -68,17 +84,32 @@ func (t *SolutionsManager) UpsertState(ctx context.Context, name string, state m
var err error = nil
defer observ_utils.CloseSpanWithError(span, &err)

sLog.Info(" M (Solution manager): upsert state >>>>>>>>>>>>>>>>>>>> %v, %v, %v", state.Spec.Version, state.Spec.RootResource, name)
if state.ObjectMeta.Name != "" && state.ObjectMeta.Name != name {
return v1alpha2.NewCOAError(nil, fmt.Sprintf("Name in metadata (%s) does not match name in request (%s)", state.ObjectMeta.Name, name), v1alpha2.BadRequest)
}
state.ObjectMeta.FixNames(name)

var rootResource string
version := state.Spec.Version
if state.Spec.RootResource == "" && version != "" {
suffix := "-" + version
rootResource = strings.TrimSuffix(name, suffix)
} else {
rootResource = state.Spec.RootResource
}

state.ObjectMeta.Labels["rootResource"] = rootResource
state.ObjectMeta.Labels["version"] = version

body := map[string]interface{}{
"apiVersion": model.SolutionGroup + "/v1",
"kind": "Solution",
"metadata": state.ObjectMeta,
"spec": state.Spec,
"apiVersion": model.SolutionGroup + "/v1",
"kind": "Solution",
"metadata": state.ObjectMeta,
"spec": state.Spec,
"rootResource": rootResource,
}

upsertRequest := states.UpsertRequest{
Value: states.StateEntry{
ID: name,
Expand Down Expand Up @@ -172,3 +203,32 @@ func (t *SolutionsManager) GetState(ctx context.Context, id string, namespace st
}
return ret, nil
}

func (t *SolutionsManager) GetLatestState(ctx context.Context, id string, namespace string) (model.SolutionState, error) {
ctx, span := observability.StartSpan("Solutions Manager", ctx, &map[string]string{
"method": "GetLatest",
})
var err error = nil
defer observ_utils.CloseSpanWithError(span, &err)

getRequest := states.GetRequest{
ID: id,
Metadata: map[string]interface{}{
"version": "v1",
"group": model.SolutionGroup,
"resource": "solutions",
"namespace": namespace,
"kind": "Solution",
},
}
target, err := t.StateProvider.GetLatest(ctx, getRequest)
if err != nil {
return model.SolutionState{}, err
}

ret, err := getSolutionState(id, target.Body)
if err != nil {
return model.SolutionState{}, err
}
return ret, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func InitializeMockSymphonyAPI() *httptest.Server {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: "fake",
Generation: "1",
ParentName: "fakeparent",
},
Expand Down
3 changes: 1 addition & 2 deletions api/pkg/apis/v1alpha1/managers/sync/sync-manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func InitiazlizeMockSymphonyAPI(siteId string) *httptest.Server {
Name: "catalog1",
},
Spec: &model.CatalogSpec{
SiteId: "parent",
Type: "Instance",
Type: "Instance",
Properties: map[string]interface{}{
"foo": "bar",
},
Expand Down
52 changes: 52 additions & 0 deletions api/pkg/apis/v1alpha1/model/campaigncontainer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
* SPDX-License-Identifier: MIT
*/

package model

import (
"errors"
)

type CampaignContainerState struct {
ObjectMeta ObjectMeta `json:"metadata,omitempty"`
Spec *CampaignContainerSpec `json:"spec,omitempty"`
}

type CampaignContainerSpec struct {
Name string `json:"name,omitempty"`
}

func (c CampaignContainerSpec) DeepEquals(other IDeepEquals) (bool, error) {
otherC, ok := other.(CampaignContainerSpec)
if !ok {
return false, errors.New("parameter is not a CampaignContainerSpec type")
}

if c.Name != otherC.Name {
return false, nil
}

return true, nil
}

func (c CampaignContainerState) DeepEquals(other IDeepEquals) (bool, error) {
otherC, ok := other.(CampaignContainerState)
if !ok {
return false, errors.New("parameter is not a CampaignContainerState type")
}

equal, err := c.ObjectMeta.DeepEquals(otherC.ObjectMeta)
if err != nil || !equal {
return equal, err
}

equal, err = c.Spec.DeepEquals(*otherC.Spec)
if err != nil || !equal {
return equal, err
}

return true, nil
}
5 changes: 0 additions & 5 deletions api/pkg/apis/v1alpha1/model/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type ObjectRef struct {
Metadata map[string]string `json:"metadata,omitempty"`
}
type CatalogSpec struct {
SiteId string `json:"siteId"`
Type string `json:"type"`
Metadata map[string]string `json:"metadata,omitempty"`
Properties map[string]interface{} `json:"properties"`
Expand All @@ -50,10 +49,6 @@ func (c CatalogSpec) DeepEquals(other IDeepEquals) (bool, error) {
return false, errors.New("parameter is not a CatalogSpec type")
}

if c.SiteId != otherC.SiteId {
return false, nil
}

if c.ParentName != otherC.ParentName {
return false, nil
}
Expand Down
Loading