Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement current state reporting for containers update agent #179

Conversation

stoyan-zoubev
Copy link
Contributor

[#167] Implement current state reporting for containers update agent

Also added xxxToString functions next to the available ParseXXX functions for containers device mappings, port mappings, mount points.

Signed-off-by: Stoyan Zoubev Stoyan.Zoubev@bosch.io

[eclipse-kanto#167] Implement current state reporting for containers update agent

Also added xxxToString functions next to the available ParseXXX functions for containers device mappings, port mappings, mount points.

Signed-off-by: Stoyan Zoubev <Stoyan.Zoubev@bosch.io>
Signed-off-by: Stoyan Zoubev <Stoyan.Zoubev@bosch.io>
@dimitar-dimitrow
Copy link
Contributor

I suggest the tests in from_container_test.go to be re-written as table driven tests as it is preferred way for unit tests in Go and is heavily used in the container-management repo . Currently some sub-test names are conflicting and test are hard to read.

func TestHostConfigParametersLogDriverConfig1(t *testing.T) {
	testCases := map[string]struct {
		logConfig        ctrtypes.LogDriverConfiguration
		nonVerboseParams []*types.KeyValuePair
		verboseParams    []*types.KeyValuePair
	}{
		"test_host_config_params_log_driver_none_verbose_%v": {
			logConfig: ctrtypes.LogDriverConfiguration{Type: ctrtypes.LogConfigDriverNone},
			nonVerboseParams: []*types.KeyValuePair{
				{Key: keyLogDriver, Value: "none"},
			},
		},
		"test_host_config_params_log_driver_json_verbose_%v": {
			logConfig: ctrtypes.LogDriverConfiguration{Type: ctrtypes.LogConfigDriverJSONFile, MaxFiles: 6, MaxSize: "100K"},
			nonVerboseParams: []*types.KeyValuePair{
				{Key: keyLogMaxFiles, Value: "6"},
				{Key: keyLogMaxSize, Value: "100K"},
			},
			verboseParams: []*types.KeyValuePair{
				{Key: keyLogDriver, Value: "json-file"},
			},
		},
		"test_host_config_params_log_driver_json_path_set_verbose_%v": {
			logConfig: ctrtypes.LogDriverConfiguration{Type: ctrtypes.LogConfigDriverJSONFile, MaxFiles: 2, MaxSize: "100M", RootDir: "/tmp/logs"},
			nonVerboseParams: []*types.KeyValuePair{
				{Key: keyLogPath, Value: "/tmp/logs"},
			},
			verboseParams: []*types.KeyValuePair{
				{Key: keyLogDriver, Value: "json-file"},
				{Key: keyLogMaxFiles, Value: "2"},
				{Key: keyLogMaxSize, Value: "100M"},
			},
		},
	}
	for _, verbose := range []bool{true, false} {
		for testFormat, testCase := range testCases {
			t.Run(fmt.Sprintf(testFormat, verbose), func(t *testing.T) {
				hostConfig := &ctrtypes.HostConfig{LogConfig: &ctrtypes.LogConfiguration{DriverConfig: &testCase.logConfig}, Privileged: true}
				actualParams := hostConfigParameters(hostConfig, verbose)

				expectedParams := testCase.nonVerboseParams
				if verbose {
					expectedParams = append(expectedParams, testCase.verboseParams...)
				}

				testutil.AssertEqual(t, len(expectedParams)+1, len(actualParams)) // +1 for privileged
				for _, param := range expectedParams {                            // assertParameters func could be added
					assertParameter(t, actualParams, param.Key, param.Value, false)
				}

			})
		}
	}
}

Signed-off-by: Stoyan Zoubev <Stoyan.Zoubev@bosch.io>
@dimitar-dimitrow dimitar-dimitrow removed the request for review from k-gostev July 18, 2023 08:20
@dimitar-dimitrow dimitar-dimitrow merged commit 255909c into eclipse-kanto:update-agent Jul 18, 2023
@stoyan-zoubev stoyan-zoubev deleted the report-current-state branch July 18, 2023 08:53
dimitar-dimitrow added a commit that referenced this pull request Aug 17, 2023
[#186] Implement containers update agent service

Merge update-agent feature branch
* Extend daemon configuration and dummy implementation for update agent (#168)
* Upgrade google.golang.org/grpc to version 1.53.0 or later (#172)
* Preparation for implementing apply of containers desired state (#175)
* Implement apply of desired state for containers update agent (#177)
* Implement current state reporting for containers update agent (#179)

Signed-off-by: Kristiyan Gostev <kristiyan.gostev@bosch.com>
Co-authored-by: Dimitar Dimitrov <dimitar.dimitrov3@bosch.io>
Co-authored-by: Stoyan Zoubev <Stoyan.Zoubev@bosch.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement current state reporting for containers update agent
2 participants